Oops, I think I forgot to add a command "break" to one of the lines of code to stop the loop from running.
Make changes to this line: if (%count == %lc) || (%i == %rn) { write $+(-l,%rn) $ctfile $nick %count | break }
This is necessary so that the loop stops, if the condition (%count == %lc) is true, thereby avoiding unnecessary checks of lines in the file.
It is assumed that when a line with the same value as the user being checked is reached, all further results in the lines of the file will be the same or even less than at the very top of the file, and since over time there can be a lot of such lines (100500+) it is necessary to stop the loop as early as possible to avoid freezing mIRC.
How correct and necessary this change is can only be determined during testing, and if it turns out to be unnecessary, it can be removed :-)
⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣀⣀⣀⡀⠄⠄⠄⠄⠸⠿⠿⠷⡢⡀
⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⡿⠿⠟⠄⠄⠄⠄⠄⠄⠄⠄⢸⡷⡄
⠄⠄⠄⠄⠄⠄⠄⠄⠉⠉⠉⡟⠦⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠧⠹⡀
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣠⢃⣄⢟⠉⠉⠉⠉⠉⠉⠉⠉⣹⢣⢆⢣
⠄⠄⠄⢀⣤⣶⣶⣶⣦⡴⢣⠎⠄⣎⢣⠄⠄⠄⠄⠄⠄⡴⡵⠁⢘⡌⢷⣶⣶⣦⣄⡀
⠄⢀⣾⣿⠿⠋⠉⠉⡿⢡⣿⣶⡀⠈⢆⢣⡀⠄⠄⢠⢎⡼⢡⣾⣿⠿⡘⡍⠉⠛⠿⣿⣦⡀ Don't stop/break me now!
⢠⣿⡿⠁⠄⠄⠄⡜⣱⠃⠘⢿⣿⡀⠈⢦⡱⠤⢴⢡⠌⢠⣿⡿⠁⠄⢣⠸⡀⠄⠄⠘⣿⣿⡀
⢸⣿⡇⠄⠄⣞⣟⠐⠓⠒⠒⠛⠛⠓⠒⡎⠐⣒⡆⢱⠄⢸⣿⡇⠄⠄⢸⢇⢻⣣⠄⠄⢸⣿⡇
⢸⣿⣇⠄⠄⠈⠻⠛⠉⠉⠉⣽⣿⠏⠉⠑⠮⣾⣷⠊⠄⠸⣿⣧⠄⠄⠈⠻⠛⠁⠄⠄⣼⣿⠇
⠄⢻⣿⣦⣀⠄⠄⠄⢀⣠⣾⣿⠏⠄⠄⠄⠄⠄⠿⠿⠗⠄⠹⣿⣷⣄⡀⠄⠄⢀⣀⣴⣿⠟
⠄⠄⠙⠻⢿⣿⣿⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠛⠿⣿⣿⣿⣿⡿⠟⠉