What's the difference between opening a file with ios::binary or ios::out or both?
ios::out
opens the file for writing.
ios::binary
makes sure the data is read or written without translating new line characters to and from \r\n
on the fly. In other words, exactly what you give the stream is exactly what's written.
Opening a file with ios::binary controls how newline characters are handled. On Windows, they are expanded to CRLF pairs. That's it - it has no effect on how things like operator<< work.