while (my $line = <$txtfile>) { next unless $line =~/Sarnia/; foreach (@InputData_Unions) { # ...