Can someone fixed or rewrite this code for me please? It's not work

Here is my code:

Code
on *:JOIN:#:{
  if ($istok(#test1 #test2 #test3,$chan,32)) {
    if ($nick == $me) { halt }
    if ($nick isop $chan) { return }
    var %host = $ial($nick).host
    var %file = autoopip.txt
    if ($read(%file,w,$+(*,%host,*))) {
      var %str $read(%file,$readn)
      if ($+(*,%host,*) iswm $gettok(%str,1,59)) {
      var %chanop $gettok(%str,2,59)
        mode %chanop +o $nick | .notice @ $+ $chan $chan - $me ( $+ $me $+ ) opped: $nick
      }
    }
  }
}

in the file autoopip.txt there are identical IPs/hosts but different #room names as follows:
188.26.59.16;#test1
161.184.143.251;#test2
id-586239.lymington.irccloud.com;#test1
id-586239.lymington.irccloud.com;#test2
id-586239.lymington.irccloud.com;#test3
id-455146.ilkley.irccloud.com;#test3
id-455146.ilkley.irccloud.com;#test2