>I was unaware of any hidden pitfalls of using read() and write().
They aren't hidden, just subtle. Here's a taste of some of the issues you need to consider when using a binary file.
Pitfall #1 (the one I was referring to): Put simply, unless you can directly convert an object to a pointer to unsigned char without invoking undefined behavior, binary I/O using that object is also undefined. Any POD type can be safely cast to a pointer to unsigned char; this is guaranteed by the standard. If you don't know whether your class is POD or not then it probably isn't, and binary I/O is undefined.
Pitfall #2: Binary I/O is a shallow copy. If your object (assuming it's POD) has pointers to dynamic memory then you'll be copying addresses, not the content of those addresses.
Pitfall #3: Binary I/O is not portable at all. You can write to a file on one platform and fail to read it on another platform (even a different version of the same platform). Even worse, differen implementations or versions of the same implementation can fail to handle the file properly if you mix them.