This is the format of an input file, 122 characters wide: Company AS PNE KREDITORPOSTERINGER Dato 30.08.16 20:10 Side 1 Per dato .....: 22.08.16 Konto ...: 12345 Customer One AS Bank 9876 54 32109 Saldo NOK ...: -1.788,00 Kontaktperson: Kreditmaks ..: Telefon .....: 12345678 Dato Forfall Bilag Faktura Tekst BetalId Valuta Belp Rest 12.08.16 22.08.16 20690 517902 Faktura 00005179023 -1.788,00 -1.788,00 0 -1.788,00 -1.788,00 Per dato .....: 22.08.16 Konto ...: 67890 Customer Two AS Bank 9750 06 50900 Saldo NOK ...: -613.651,66 Kontaktperson: Nobody Kreditmaks ..: Telefon .....: 23456789 Dato Forfall Bilag Faktura Tekst BetalId Valuta Belp Rest 03.03.16 20.08.16 20224 959217542 Faktura 0572432251629592175421 -15.413,70 -15.413,70 07.04.16 20.08.16 20333 959219158 Faktura 0572432251629592191584 -8.733,20 -8.733,20 0 -24.146,90 -24.146,90 This is the end result I need, written to a new text file (csv), separated with ";" : 12345;Customer One AS;9876 54 32109;12.08.16;22.08.16;20690;517902;Faktura;00005179023;-1788,00;-1788,00; 67890;Customer Two AS;9750 06 50900;03.03.16;20.08.16;20224;959217542;Faktura;0572432251629592175421;-15413,70;15413,70; 67890;Customer Two AS;9750 06 50900;07.04.16;20.08.16;20333;959219158;Faktura;0572432251629592191584;-8733,20;-8733,20; which actually is: Konto;CustomerName;Bank;Dato;Forfall;Bilag;Faktura;Tekst;BetalID;Belp;Rest;