the default stdout device on Win32 is not in binary
mode, so LF characters are being translated into CRLF
i think you need to explicitly change the mode with this
code
#include <io.h> // for _setmode
#include <fcntl.h> // or _O_BINARY
_setmode( fileno( stdout ), _O_BINARY );