Huh. That single line replacing the entire loop worked perfectly. Thanks!

But what do you mean I was creating an empty file? You're right, filePathString is the path to a file that already exists. I thought this:
Code:
ofstream fileStream (filePathString, ios::out | ios::binary);
would open that file, and then seekp would work as expected? What's the difference between what I have and what you suggested in #3?