Use distinct variable names (writeErr, closeErr) to avoid shadowing the outer err, so a deferred close failure is still captured.
Use distinct variable names (writeErr, closeErr) to avoid shadowing the outer err, so a deferred close failure is still captured.