Fix issue #505 removing trailing \r from lines in Windows text files

Window uses \r\n to split lines. so, for text files from Windows, when
\n is used as delimiter, \r is still appear at the end of lines.

The code checks to see if \n is used as delimiter and end of a line is
\r, then \r is removed from the line