Fix absolutely braindead mistake (mine) which caused file to be closed before it was used.