title: fstream for reading and writing
body: <p>In test.txt file i have one word "aa". I want to replace it with "aa1". However, the program below does not change the file. What's wrong?</p>
  
  <pre><code>#include &lt;string&gt;
  #include&lt;iostream&gt;
  #include&lt;fstream&gt;
  using namespace std;
  
  int main()
  {
      fstream iofile("test.txt",ios_base::in|ios_base::app);
      if (!iofile)
              cerr &lt;&lt; "Unable to open file!";
  
      string word;
      iofile &gt;&gt; word;
      word.push_back('1');
      iofile.seekg(0);
      iofile &lt;&lt; word;  
  }
  </code></pre>