your write converted data but you should write raw binary data:
resFile.write( reinterpret_cast< const char* >( &( i->first ) ), sizeof( boost::uint32_t ) );
resFile.write( reinterpret_cast< const char* >( &middle ), sizeof( double ) );