Improve error handling when opening files

Create/open the file at the very last moment, so that there's no need to
close or remove it when we run out of memory.

Update binaries.
Fix grammar in comment