Walk through each line of the next file (#2) and do a binary search on the #1 file (based on the number of lines).
If you find the string; write it on another temp file (#temp1).
After you finished with #2, sort #temp1 go to #3 and do the same search but this time on #temp1, not #1, which should take much less than the first one as this only has repeated lines.
Repeat this process with new temporary files, deleting previous #temp files. Each iteration should take less and less, as the number of repeated lines diminishes.