closing file before trying to use it.