I implemented some serialization / deserialization using C++ after some help on this forum. The file seems to be written correctly but when I read it, new lines are ignored
Today you almost never need to implement your own low-level serialization.
Try JSON, BSON, Protocol Buffers, MessagePack or XML.
There are quite a lot of libraries, that will do it better than "roll-your-own"...
You intended to write a binary serialization, but you insert EOL ('\n') characters. That's not a good choice of dividing a binary stream into tokens.