hi, i have this code
#include <fstream.h>
#include<iostream>
using namespace std;
int main (char argc)
{
for(;;)
{
fstream file;
file.open("file.txt");
cout << "Enter new high score." << endl;
double n2;
cin >> n2;
double n1;
file >> n1;
if(n1 > n2)
{
cout << "You didn't beat the high score of "<<n1<<"."<< endl;
}
if(n1 < n2)
{
cout << "You beat the high score of "<<n1<<"."<< endl;
file << n1 << endl;
}
if(n1 == n2)
{
cout << "Your score is the same as the high score" << endl;
}
file.close();
}
}
and for some reason, after i enter a score higher than the high score, the text file doesnt change. any solutions?