in reply to end of line help

p789123:

Try adding binmode(OUTPUTFILE); just after you open it (just like you do for the other file handle). It's common in Windows machines to use 0x0d 0x0a (\r\n) as line endings in files, so perl may translate it to Windows mode on output unless you tell it not to.

...roboticus