I just tested a few things and I am able to replicate your problem
Your input files are dos files and _not_ unix/linux files (\r\n vs \n line endings).
This will show if the above is the case: od -c file
If the following is present, it is a dos file: \r \n
. It should be \n (no \r).
Changing these files can be done in different ways (tr, dos2unix to name just two), but you want to create unix files in the first place. You don't tell if these files are created automatically or by hand and if this is done in a linux or windows environment, so I cannot give you any specific advice.
For now: open the file(s) in vi, type :set ff=unix
in command mode and safe (:wg) the files.
Hope this helps.