Properly close file

File was being left open, so just fixed that