title: fstream doesn't write file
body: <p>I've been working on a small programm that put all the images I need for my 3D engine into a single file, but for unknow reasons when I try to use fstream to write into a file, it doesn't return any error, but still doesn't write anything.</p>
  
  <p>for exemple, I have a simple function that initialize a new file :</p>
  
  <pre><code>void initPAK(fstream&amp; pakfile, image firstImg)
  {
      PAKheader head;
      head.sign[0]    = 'P';
      head.sign[1]    = 'A';
      head.sign[2]    = 'K';
      head.nbdata     = 1;
      head.index.push_back(sizeof(head.sign)+sizeof(head.nbdata)+sizeof(uint32_t));
  
      if(pakfile.is_open())
      {
          pakfile.write(head.sign, sizeof(head.sign));
          pakfile.write((char*)&amp;head.nbdata, sizeof(head.nbdata));
          for(uint32_t n=0; n&lt;head.index.size(); n++)
          {
              pakfile.write((char*)&amp;head.index[n], sizeof(head.index[n]));
          }
  
          pakfile.write((char*)&amp;firstImg.width, sizeof(firstImg.width));
          pakfile.write((char*)&amp;firstImg.height, sizeof(firstImg.height));
          pakfile.write((char*)&amp;firstImg.channels, sizeof(firstImg.channels));
          for(uint32_t n=0; n&lt;firstImg.data.size(); n++)
          {
              pakfile.write((char*)&amp;firstImg.data[n], sizeof(firstImg.data[n]));
          }
  
      }
      else
      {
          cerr &lt;&lt; "unable to open" &lt;&lt; endl;
      }   
  }
  </code></pre>
  
  <p>And I use it like that :</p>
  
  <pre><code>    fstream fileop;
      fileop.open("bin_file", fstream::in | fstream::out | fstream::trunc | fstream::binary);
  
      unsigned char zdata[] = {
          255, 0, 0,
          0, 255, 0,
          0, 0, 255,
      };
  
      image zimg;
      zimg.width = 3;
      zimg.height = 1;
      zimg.channels = 3;
      for(int i=0; i &lt; 9; i++)
      {
          zimg.data.push_back(zdata[i]);
      }
  
      initPAK(fileop, zimg);
  
      fileop.close();
  </code></pre>
  
  <p>But the file "bin_file" his never write nor created. I saw in an other stackoverflow's question that I should use flush() but I didn't work either. The strangest thing his that this function use to work, until I replace ofstream to fstream I believe.
  What am I doing wrong ?</p>