File handling, C++-way

#include <fstream>

// input and output file as global variable
ofstream ofile;
ifstream ifile;