Close file before trying to update