Ths is just a guess, since nobody else seems to have any ideas yet...
I used to have problems when I would create/edit a Perl script on my Windows 9x box and FTP it to the *nix server... the line break characters were all encoded in PC file format. I save the files in Unix format and that fixes it. Could something like that be your problem? The fact that it is fixed when you open/save the file without any changes makes me think it may be this or something similar.