input line should also have <code>direction=2,</code>. In the sample above, first line matches <code>3333</code> but not the second criteria. The second line fails even though it has <code>642</code> since it is not immediately after <code>clear_number=</code>. The <code>list.txt</code> file can have 10K-50K lines and <code>ip.txt</code> is around 10GB.<p>Here's a slightly modified answer based on existing solutions on that thread. Since the data present in <code>list.txt</code> has to be partially matched 