This makes bitcoin-wallet dump fail if writing the dump file does not complete successfully.
Previously, DumpWallet() only checked whether the dump file could be opened. If later writes or close failed, the tool could still return success and print the private-key warning, leaving a truncated dump file behind.
The change adds write/close checks while dumping wallet records. If writing fails, the partial dump file is removed and bitcoin-wallet returns an error.