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?
#include <string>
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream iofile("test.txt",ios_base::in|ios_base::app);
if (!iofile)
cerr << "Unable to open file!";
string word;
iofile >> word;
word.push_back('1');
iofile.seekg(0);
iofile << word;
}