One annoying thing with text file is that files created on DOS/Windows machines have different line endings than files created on Unix/Linux. DOS uses carriage return and line feed
\r\n as a line ending which Unix uses just line feed
\n. So in the end you finish with a lot of supernumerary CTRL-M characters. To get rid of it you can:
sed -e "s/^M//" filename > newfilename
Inside vi [in ESC mode] type:
To enter ^M, type CTRL-V, then CTRL-M (hold down the CTRL key then press V and M in succession).