title: python TypeError: str object is not an iterator
body: <p>I'm writing a code which searches in a text file for a value and print the previous line; 
  but I faced 2 problems , First I didn't find a way to print the previous line and when  I wrote the code to print the next value I got an error .</p>
  
  <p>Code :-</p>
  
  <pre><code>with open('Perfix/prefix.txt') as f:
      lines = f.readlines()
      for line in lines:
          if "100" in line:
              print (next(line))
  </code></pre>
  
  <p>Supposed Scenario :-</p>
  
  <p>The code should search in prefix.txt file to find the line with the value 100 exactly then it should print the previous line . Thats it !!</p>
  
  <p>Error :-</p>
  
  <pre><code>Traceback (most recent call last):
    File "1.py", line 7, in &lt;module&gt;
      print next(line)
  TypeError: str object is not an iterator
  </code></pre>
  
  <p>What is the error ? Also could you please advise how to print the "previous" not the next line ?</p>
  
  <p>Example :-</p>
  
  <p>File prefix.txt</p>
  
  <pre><code>00
  122
  141
  1525
  1162
  1547
  100
  125
  15321
  1100
  1513
  142100
  </code></pre>
  
  <p>Output :-</p>
  
  <pre><code>1547
  </code></pre>