#include <iostream>
#include <fstream>
using namespace std;



int main() {

  ofstream outfile;
  bool quit;
  char z;

  outfile.open( "test.dat", ios::out );
  if ( ! outfile ) {
    cerr << "error opening output file :-(" << endl;
    exit( 1 );
  }
  quit = false;
  while ( ! quit ) {
    cout << "enter a letter (or q to quit):";
    cin >> z;
    if ( z == 'q' ) {
      quit = true;
    }
    else {
      outfile << z;
    }
  }
  outfile << endl;
  outfile.close();

  return 0;

} // end of main()
