in reply to How can i print to my outfile handle?

open(my OUT,">$peptstr1") or die $!; open(my IN,$genpept);

my OUT and my IN are syntax errors and won't work.    You need to use scalar variables for that to work.    Also, you should always verify that the file opened correctly:

open my $OUT, '>', $peptstr1 or die "Cannot open '$peptstr1' because: +$!"; open my $IN, '<', $genpept or die "Cannot open '$genpept' because: $ +!";



while (my $records = <IN>){ #$i++; chomp $records; my @genpept; push @genpept,($records); print"Processed infile record: $.\n"; foreach(@genpept){ print "$_"; } }

You don't print to the OUT filehandle so everything is going to STDOUT and not your file.