Can't follow all the changes anymore, but at least one versions seems to be working. Can you paste the code of the file here again?
It's so slow because of the .txt file. And the larger the .txt file becomes, the longer it will need to load.
The Algo is as follows:
1. Open/Download the file
2. Read the file (line by line)
3. Delete special chars
4. Build an array
5. Go through the whole array
6. Display matches with user id.
What we can do against this is:
Write a script to to import the whole txt into a SQL-DB. This would increase the speed to "infinity". But once the DB is established you need to keep care of it and save all new data to this DB.
I am not sure how you process all the data. Maybe you can tell us how exactly you get the data and how you are saving it into your .txt file.