Text files created in Windows and Linux have different line endings. In Windows it is ^M$ (CR-LF) and in Linux it is $ (LF). It causes text files come from different system cannot be read perfectly well by text editor.

Here are the commands dos2unix and unix2dos that convert text file format between DOS/Mac (Windows & Mac OS) and Unix (Linux).

Ubuntu user using following to get above commands (test in Ubuntu 10.10):

sudo apt-get install dos2unix

Examples, to convert a.txt into unix format and keep the date stamp of output file same as input file.

dos2unix -k a.txt

To convert a.txt from Mac to Unix format.

dos2unix -c mac a.txt

-k — Keep the date stamp of output file same as input file.
-o –New file mode. Convert the infile and write output to outfile.
File names must be given in pairs and wildcard names should NOT
be used or you WILL lose your files.
-c –Set conversion mode. Where convmode is one of: ascii, 7bit, iso,
mac with ascii being the default.

More about how to use dos2unix and unix2dos, read:

man dos2unix