Fix calls to file:close
Merge pull request #1 from abustany/upstream-fixes

Fix calls to file:close. Thx abustany