// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
   cout << "Old numbers:" << endl;
   ifstream f1("test.dat");
   while(!f1.eof())
   {
      int v1;
      f1 >> v1;
      if(f1) cout << v1 << endl;
   }
   int v2;
   cout << "Enter number: ";
   cin >> v2;
   ofstream f2("test.dat", ios::app);
   f2 << v2 << endl;
   f2.close();
   return 0;
}
