Binary files need to be opened with ios::binary