my $body; { local $/=undef; open MSGBODY, "<$file" or die "Could not open $file: $!\n"; $body=; # slurp message body close MSGBODY; } for $member (keys %CONTACT) { ... print $fh $body; ... }