my $switch = 1; while ($switch == 1) { if (($position < $end) && ($position >= $start)) { print OUT "$SNPs[$placeholder]\n"; $placeholder++; } else { $switch = 0; $count++; } } }