Once you've got the logic working, think about makeing it a function that can be called. Test again.. then, with the core code working, it's easier to expand the functionality of the overall script.

Everything after this line:
$InsertData = '..KOMMUNE $kommunenr' ; data line to insert
up to the Next can be put in a function and called by
ModFile($File, $SearchData, $InsertData)

Speaking of that line, it should be more like:
$InsertData = '..KOMMUNE ' + $kommunenr ; data line to insert
so you don't put Vars inside Strings (bad.. very bad!) ;\)



Just my $0.42...

Glenn
_________________________
Actually I am a Rocket Scientist! \:D