Moved the opening of a file to a better spot