Empirically, on Windows,
put_code(10)
first puts the code (13) of a carriage return, then a 10. This makes it difficult or non-obvious to write Unix-style text files under Windows, and should be documented somewhere nearby. IMO the DOS CRLF convention is not a character encoding issue.