in reply to Why do we need to close filehandles?
You close your files as soon as possible so that you can check for errors. This is needful especially when writing.
close $fh or die "could not close file: $!\n";