changed procedure of buffering input file