Did you try opening your files in binary mode instead of text mode?
It works. I opened a file in binary mode:
std::ofstream os("test.txt", std::ios::binary); os << "\n";
and except for "\r\n" it wrote "\n" on Windows. This means I have to read and write in binary mode and the ciphered file can be read on any OS. Now I don't have to worry about this problem anymore. I forgot that std::ios::in/out opens files in text mode.
PS: My program is in it's final stage. You enter an integer key and the algorithm ciphers it. Only the correct key can decipher it. The only question is what shall happen if you need too many tries for entering the correct key.