Fixed first-run bug where file was never closed