The scanner strips the actual newlines, so to write you have to append them manually. Doing so means you have to define some constant because they're different in Linux and Windows, but that seemed overkill to me. Using the library deals with this.