Fix issue #505 by removing trailing \r from lines when \n is used to split lines for text files from window

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