Just to provide context, what you are experiencing is the concept of "line feed" (LF) and "carriage return" (CR) and "newline" and how they are represented in different operating systems (Windows, Linux, ...) and runtimes (e.g. fopen with text/binary modes):
https://en.m.wikipedia.org/wiki/%5Cn