Sounds like your input file has non-native newlines in it. Other posters suggest ways of compensating for this in your code. I might suggest that you fix this problem at the source by repairing the transfer mechanism you use so that ASCII newline conventions are translated between the different OS's. Generally transferring a file via FTP in "ASCII" mode will do this, as should HTTP User-Agents and even Samba. If you're using a proprietary transfer process to get this file to your system, you should look into augmenting it with support for newline translations.