Issue fix 211

This takes the proposed code from issue #211 and puts it into a commit/pull-request. I hope the original author @tstgruby is fine with this.
The second commit deals with further CRLF related problems that are further described in #287.