my $atleastone = 1; while ($atleastone) { $atleastone = 0 ; my @l = () ; foreach my $op (@handles) { my $c2 ; ++$atleastone and (undef, $c2) = split if defined($_ = <$op>) ; push @l, $c2 || "0" ; } ; print OUTFILE join("\t", @l), "\n" ; } ;