Use dos2unix
- "[a] program that converts plain text files in DOS/MAC format to UNIX format" - or a similar command.
Repositories like Git or Hg they have support for 'line ending normalization'. Using a version control system is great for other reasons too!
If transferring via [S]FTP/SCP (eg. WinSCP) specify "TEXT mode" for the transfer the conversion will be done automatically - the newline transcoding is done as part of the copy/transfer process itself.
A number of "advanced" text editors (eg. [x]emacs, [g]vim, sublime, notepad++, and even Visual Studio) can also repair/normalize such files. These editors can also be used to write the file from the start :)