while ( ) { chomp; if ( /^SEQRES[\s]{2,5}(1|2)\s/ ) { if ( $1 eq "1" ) { print "$_\n"; print OUTFILE "$_\n"; } else { last; } } }