Here's a little re-write of your code, and a quick test shows it to be working as expected.
Code:
 menu nicklist {
  -
  Notify BanList Settings
  .Add Nick: banlist add $$?="Nick To Add"
  .Remove Nick: banlist del $$?="Nick To Remove"
  .View Ban NickList:/run NB.txt
}
alias banlist {
  notify $iif($1 == del,-r) $2
  write $iif($1 == del,-ds $+ $2) nb.txt $2
}
on *:notify: {
  if ($read(NB.txt,s,$nick) == 2) {
    var %a = 1, %b = $chan(0)
    while %a <= %b {
      if ($me isop $chan(%a)) ban $chan(%a) $nick
      inc %a
    }
  }
}