$textarray[$iwrdnum][1] = $tagfields[0]; #the member located in the position 0 of the tagfields array, is placed into position 1 in the textarray array $textarray[$iwrdnum][2] = $tagfields[1]; $textarray[$iwrdnum][3] = $tagfields[2]; $textarray[$iwrdnum][4] = $tagfields[3]; $textarray[$iwrdnum][5] = $tagfields[4]; $iwrdnum++; }#end loop 2 for ($i = 0; $i <@textarray; $i++) {#start loop 3 if ($textarray[$i][1] =~ /\b(nn|nns|nvbg|np|nps|npl)\b/) {#start if conditon for ($i3=1; $i3<=9; $i3++) #HERE IS WHERE I THINK THE PROBLEM MUST BE. What I think I'm doing is starting at the next row to the 9th row down, looking row by row { #start for loop if ($textarray[$i][1] =~ /\b(at|ati)\b/ ) #if the tag is at or ati then {#start if condition print (OUTFILE "$textarray[$i][0]$textarray[$i+1][0]$textarray[$i+2][0]$textarray[$i+3][0]$textarray[$i+4][0]$textarray[$i+5]\n "); }#end if condition }#end for loop }#end if condition }#end loop 3