Windows, Linux/Unix and Macs all use different line endings.
Linux/Unix = \n (newline)
Windows = \r\n (carrage return, newline)
Mac = \r (carrage return)
So if you are writing to a specific platform (\n should work regardless tho) then use the correct format as per above.
In Windows, WordPad will properly format a text file with just \n whereas notepad will not.