Maybe you just shouldn't be using QDataStream to write the file in the first place? Why don't you just use QFile::write() or QTextStream?