title: Reading a binary continuously changing file on Windows
body: <p>I'm have trouble reading a changing file, during the course of the app life time.
  I'm not able load changes after writing in the file, unless I stop and restart the app. It works fine on OSX, but not on Windows.</p>
  
  <p>Here is the singleton class:</p>
  
  <pre><code>StoreManager::StoreManager() {
     // Verify that the version of the library that we linked against is
     //   // compatible with the version of the headers we compiled against.
     GOOGLE_PROTOBUF_VERIFY_VERSION;
  
    // file = "data.db";
    // // Read the existing data.
    input = fstream(file, ios::in | ios::binary);
    if (!input) { 
        input.close();
        cout &lt;&lt; file &lt;&lt; ": File not found. Creating a new file." &lt;&lt; endl;
        fstream output(file, ios::out | ios::trunc | ios::binary);
        if (!output)
            cout &lt;&lt; file &lt;&lt; ": Failed to create a new file" &lt;&lt; endl;
        else{
            appData.SerializeToOstream(&amp;output);
            output.close();
            cout &lt;&lt; file &lt;&lt; ": New empty file created " &lt;&lt; endl;
        }
  
        input = fstream(file, ios::in | ios::binary);
        if (!input) { 
            cout &lt;&lt; file &lt;&lt; ": File not found. Failed to creating a new file." &lt;&lt; endl;
        }
    } 
  
    if (!appData.ParseFromIstream(&amp;input)) {
        cerr &lt;&lt; "Failed to parse in date storage." &lt;&lt; endl;
    } 
  }
  
  AppData* StoreManager::getData() {
    return &amp;appData;
  }
  
  void StoreManager::save(){
    // Write back to disk.
    fstream output(file, ios::out | ios::trunc | ios::binary);
    if (!appData.SerializeToOstream(&amp;output)) {
       cerr &lt;&lt; "Failed to write in date storage." &lt;&lt; endl;
    }
    output.close();
  }
  </code></pre>
  
  <p>Expected:
  To be clear, When modifying the stream and then calling save(), I should see the changes applied in appData.</p>
  
  <p>Actual bug(bug is on Windows only):
  My data stays the same until the moment I close and reopen the app. then I see the previously save changes.</p>
  
  <p>Any help would be greatly appreciated.</p>