fix an embarassing logic error when checking whether closing a file succeeded