title: for loop to a list comprehension
body: <p>Hey all,
  I have some code to read certain lines from a file, and wanted to know if it would run faster as a list comprehension or a generator expression/function. And if it does run faster, how would the code look? Still learning Python. Thanks for your help</p>
  
  <pre><code>input = open('C:/.../list.txt', 'r')
  output = open('C:/.../output.txt', 'w')
  
  x=0
  
  for line in input:
      x = x+1
      if x &gt; 2 and x &lt; 5:
          output.write(line)
  </code></pre>
  
  <p>list file has</p>
  
  <pre><code>1
  2
  3
  4
  5
  </code></pre>
  
  <p>output in new file is</p>
  
  <pre><code>3
  4
  </code></pre>