the <<operator will format your data as text. While the record will output data in the same format as in memory. So, if you are writing binary files, you want to use write.
However, if you write non-subtypes, you need to be careful. You cannot just say:
write( &mystring, sizeof(std::string) );
- , .