in reply to CRLF question

This node gives a couple of examples of dealing with CR & LF in the context of chomping to remove line terminators. The second example, opening a file in ":crlf" mode, could be what you need.

Cheers,

JohnGG