on *:TEXT:!checkz:#: { var %c = 1 while ($read(Blacknickstotal.txt, %c) <= 21) && ($read(Blacknickstotal.txt, %c) > $read(totalscheck.txt, 1)) { write -l1 totalscheck.txt $read(Blacknickstotal.txt, %c) inc %c } } In variables %c = 4 And the 4th line is the largest number, however, it isn't writing it to totalscheck.txt