Close file handle when opening