in reply to line ending troubles
Use dos2unix, flip or flip: Newline conversion between Unix, Macintosh and MS-DOS ASCII files to convert.
Or see Super Search: newline regex.
HTH,