my $infile = "/Users/me/Desktop/CCDS.current.txt"; my $outfile = "/Users/me/Desktop/withdrawndata.txt"; open my $infh, $infile or die "$infile: $!"; open my $outfh, '>', $outfile or die "$outfile: $!"; #remove the header my $firstline= <$infh>; chomp $firstline; while (<$infh>){ chomp; my @fields = split /\t/; if($fields[5] =~ m/Withdrawn/){ print $outfh "$_\n"; } } close $infh; close $outfh;