Use a safe wrapper for closing I/O streams, where it makes sense.