#include <fstream> 
#include <iostream> 
#include <string> 
using namespace std; 
  
int main() 
{ 
  // open scores.txt (see text section 10.2.2) 
  string scoreFile = "scores.txt"; 
  ifstream fin; 
  fin.open(scoreFile.c_str()); 
  if (!fin.good()) throw "I/O error"; 
  // create a variable, read it from scores.txt (10.1.5) 
  int wins; 
  fin >> wins; 
  fin.ignore(1000, 10); 
  cout << "You won " << wins << " time(s)." << endl; 
  // create a variable, read it from scores.txt (10.1.5) 
  int losses; 
  fin >> losses; 
  fin.ignore(1000, 10); 
  cout << "You lost " << losses << " time(s)." << endl; 
  // close scores.txt (10.1.3) 
  fin.close(); 
  // play the game(s) in a loop here (MISSING)
  // ...for each win, do wins++; 
  // ...for each loss, do losses++; 
 
  // rewrite scores.txt with the latest scores 
  ofstream fout; 
  fout.open(scoreFile.c_str()); 
  if (!fout.good()) throw "I/O error"; 
  fout << wins << endl; 
  fout << losses << endl; 
  fout.close(); 
} 
