I don't see an immediate flaw in your script.
From how you use $read I assume the .txt file only contains nicknames?
Also, you can probably use local variables instead of global ones here (or do you need the variables in other events too?)
I have rewritten the script to be more condensed/'simpler'.
Does this perhaps work for you?

Code:
var %announcer = 1
while ($read(remaining.txt,n,%announcer)) {
  if ($v1 ison #test) {
    notice $v1 $1-
    write -ds $+ $v1 remaining.txt
  }
  inc %announcer
}