you cutted last 4 bytes in double. It should be like:
outputFile.write(reinterpret_cast<char*>(&mean), sizeof(double));