I haven't found an event which triggers when an individual retry fails. The only one I've seen is something like this:
on *:CONNECTFAIL: {
echo -s event $event server $server servertarget $servertarget serverip $serverip port $port network $network / (1-) $1-
}
but this doesn't trigger if the number of retries is not yet reached, which would force you to set the number of retries to something very low, which would force you to have the CONNECTFAIL event contain the /server command to join the server again. The other way would be a timer that gets launched during ON DISCONNECT which would use /filter or some other means to inspect the last few lines of the status window to look for a line containing the 'unable to connect' message, comparing the timestamp to see if it's newer.
Something else you should do with your handling of your text file is to check if the value is $null which means you've read past the last line of the file. You should also be in the habit of ALWAYS using the nt switches with $read unless you specifically want the 1st line of the file to be used as if it's a number containing the number of lines in the file, and unless you specifically want to spend extra CPU time checking the line for $identifier and %variable words to be evaluated. Something like:
if (!%proxynum) { set %proxynum 1 }
:label
inc %proxynum
var %proxyinfo = $read(proxylist.txt, %proxynum)
if (%proxyinfo == $null) { set %proxylist 1 | goto label }
; proxy connection code goes here
/firewall on $read(proxylist.txt,nt, %proxynum)
I don't know what your text looks like, but as you wrote it the 1st line was something that was not to be used. If that's not the case, the 1st line should be changed to 0 instead of 1.