// reading from a file and writing to a file in append mode

#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	int nextNum = 0;
	int newNum = 0;

	ifstream infile("C:/Documents and Settings/PSU_USERNAME/Desktop/numbers.txt");

	while (!infile.eof())
	{
		infile >> nextNum;
		cout << nextNum << endl;
	}

	infile.close();

	cout << "What is today's lottery number? ";
	cin >> newNum;

	ofstream outfile("C:/Documents and Settings/PSU_USERNAME/Desktop/numbers.txt", ios::app); // append mode
	outfile << newNum << endl;

	outfile.close();

	system("pause");
	return 0;
}// end of main
