What did you debug exactly? Nothing. Your first and second codes are entirely the same if not for the main top if condition which has nothing to do with your issue. There's no new informations about what's wrong, AND your original description of the problem does not match reality, this is why nobody is helping you.
You should consider stop asking questions on the forums and ask them on IRC where it won't takes 3 weeks for people to figure out what's going on.
The script itself works completely fine, obviously.
What you completely failed to mention is that the loop itself and the nicknames themselves are found correctly, it is in how you display the nickname that your count starts back at 1 instead of 51, which is quite obvious since the only thing you use for that count is.. \n from $regsubex, which is always ranging from 1 to 50 (or less on last iterations).
Achieving what you want is of course entirely possible, you need to change the logic of the loop, either add a variable that increase and count it in the main count or stop looping on $gettok(,1-50) with $deltok().
Not giving you a direct answer here, please join IRC.