To remove ^M characters from a file, you need to execute dos2unix on that file.

Code:
dos2unix file