close input file immediately after reading