Read the next word in a file in python
<p>I am looking for some words in a file in python. After I find the file I need to read the next two words from the file. I've looked for some solution but I could not find reading just the next words. </p>

<pre><code># offsetFile - file pointer
# searchTerms - list of words

for line in offsetFile:
    for word in searchTerms:
        if word in line:
           # here get the next two terms after the word
</code></pre>

<p>Thank you for your time.</p>

<p>Update: Only the first appearance is necessary. Actually only one appearance of the word is possible in this case.</p>

<p>file:</p>

<pre><code>accept 42 2820 access 183 3145 accid 1 4589 algebra 153 16272 algem 4 17439 algol 202 6530
</code></pre>

<p>word: ['access', 'algebra']</p>

<p>Searching the file when I encounter 'access' and 'algebra', I need the values of 183 3145 and 153 16272 respectively.</p>
