close file pointer before exiting function