on *:TEXT:!checkz:#: { write -l1 totalscheck.txt $read(Blacknickstotal.txt, 1) /var %c 2 | while ($read(Blacknickstotal.txt, %c) <= 21) && ($read(Blacknickstotal.txt, %c) > $read(totalscheck.txt, 1)) { write -l1 totalscheck.txt $read(Blacknickstotal.txt, %c) } | inc %c } Blacknickstotal.txt :- 9 10 15 16 21 20 Only ever writes the number 10. The purpose of the script is to first write line one of blacknickstotal.txt, then starting at line 2 of of the .txt file see if it's under 21, but larger than the number on line of totalscheck.txt