Properly close input file