#include <fstream> 
#include <iostream>
using namespace std;

//#define WRITE

main()
{
   #ifdef WRITE 
   cout<<"File writing ..."<<endl;   
    ofstream outfile("TEST.TXT"); 
    outfile << "I fear thee, ancient Mariner!\n";
    outfile << "I fear thy skinny hand\n";
    outfile << "And thou art long, and lank, and brown,\n";
    outfile << "As is the ribbed sea sand.\n";
   #else 
    cout<<"Reading from file ..."<<endl;
    const int MAX = 80;    //size of buffer
    char buffer[MAX];      //character buffer
    ifstream infile("TEST.TXT"); //create file for input
    while( infile )       //until end-of-file
    {
       infile.getline(buffer, MAX); //read a line of text
       cout << buffer << endl; //display it
    }
   #endif    
    system("pause");
}
