Very old thread that is still very relevant.
The easiest way to handle this and other situations when you get text data from different operating is to start by normalise the information first.
This is Javascript but you should be able to change it into any other language easy enough.
body = body.replace(/(\r\n|\r)/g,"\n");
In most languages it could be translated into this (but in JS it will just replace the first occurance.)
body = body.replace("\r\n","\n");
body = body.replace("\r","\n");
It will simply make sure that newline is represented by "\n" , if you want for instance windows format you simply add after the above..
body = body.replace("\n","\r\n");