if ($line =~ /$arc/) { $s = 'true'; } # New test here: last if ($s && $line =~ /^[\s\n\r]*$/); if ($s) { print OUTPUT $line; }