The tar writer was only closed on the success path, so any early return
from the loop left it unclosed. Use a named return value and close it in
a defer, preserving the first error seen.
This is a pre-existing issue, unrelated to the hard link handling in the
preceding commit.
Signed-off-by: Varun Gokulnath <vagokuln@microsoft.com>