/* I want to transfer the content from the first file ("constituencies") to the second ("temp") and then delete the original ("constituencies") file then rename() ("temp") to ("constituencies") so it can be refreshed with a specific entry/line be deleted from the file by first finding it and then not adding it in the newly generated file ("temp") and then deleting the old ("constituencies") file and renaming ("temp") as the new ("constituencies") but both of my files get deleted in the process, please help */
void updateOrDelete()
{
fstream constituencies("constituencies.txt", ios::out | ios::in);
fstream temp("temp.txt", ios::out | ios::in);
string deleteline;
string line;
cout << "Which constituency do you want to remove? \n";
cin >> deleteline;
while (getline(constituencies, line))
{
if (line != deleteline)
{
temp << line << endl;
}
}
constituencies.close();
temp.close();
remove("constituencies.txt");
rename("temp.txt", "constituencies.txt");
}