You need to understand something, you shouldn't expect windows/mIRC to read the data (internally) the same way each time, you won't necessarily get the same number of byte read each time, that's why you can get different result each time.
You need to read the data in a better way, you are actually reading it making a false assumption, which is "if I can get the line with the name when my sockread event triggers, I can get the next lines from that same sockread event".
A better way would be to use a variable to count whenever you are past the line with the nickname or not, and then use that variable to count the lines:
if (%name isin %temp) set %count 1
elseif (%count isnum 1-2) inc %count
else {
if (%count == 3) set %temp.1 $remove($gettok($remove(%temp,$chr(32)),3,62),</td)
else set %temp.2 $remove($gettok(%temp,2,62),</td)
if (%temp.1) && (%temp.2) {
msg %chan Total: %temp.1 $+ ; Last: %temp.2
sockclose stats
unset %count %temp.1 %temp.2
}
inc %count
}
this is untested.