open (MAIL, ">/home/brian/mail.txt") or die "Can't open: $!"; print MAIL "\n"; while () {print MAIL $_} close MAIL or die "Can't close: $!"