The first version of the script worked, the second does not find matches.
There may be an error in the code.
On my PC, 100 keys found out of 100, ....

Did you set the same parameters in both scripts?
About an hour and a half ago, I copied both scripts, created a database and launched the search script. I didn't change anything in the parameters.