... #Output line of matching data to output file for the relevant sector print $fh[$dataSector] "$mydata\n"; ...