title: Yield n lines from a Generator class in Python
body: <p>I want to print n lines from a file everytime a Generator class is called. </p>
  
  <p>I have tried the following:</p>
  
  <pre class="lang-py prettyprint-override"><code>class FileReader:
      def __init__(self, file):
          with open(file, 'r') as fin:
              read_file = fin.read()
  
              # gen-comp yielding stripped lines
              lines = (line.strip() for line in read_file)
              print(lines)
  </code></pre>
  
  <p>This simply returns all the lines.</p>