If you are stuck with using flat text files, you could probably split the files up some way, like hashing off the third and fourth digit in the number. Then you could store the results for item Y245624222348 in a file called 56 and search through that file. An even faster way might be to create individual files for each result, and store them in directories that are hashed the same way... so the above file would be called Y245624222348 in the /56/ directory. Your operating system is probably quicker looking for files in it's file system than searching for a line in a text file. Of course, you know how many files you might expect to have...these are just suggestions.