This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
your problem statement is abstract, maybe you could post your code snippet in here
I am guessing that your problem is due to non printable characters such as carriage return,form feed, tabs that you may get this issue
keep in mind that in windows newline consists of "\r\n" and not "\n"
Do one test, open same (output) file in notepad and wordpad and see if there is any difference in view in both, if yes, then the problem is
definately due to newline characters.
There is a method by which you can find out the system's newline char but i leave that to you to figure out.