Found the solution. Might be useful for other newbies in future:
To get rid of windows new line character:
% sed -e "s/^M//" filename > newfilename
To enter ^M, type CTRL-V, then CTRL-M. That is, hold down the CTRL key then press V and M in succession.
http://www.webmasterworld.com/forum40/66.htm