title: ValueError: seek of closed file Working on PyPDF2 and getting this error
body: <p>I am trying to get text out of a pdf file. Below is the code:</p>
  
  <pre><code>from PyPDF2 import PdfFileReader
  with open('HTTP_Book.pdf', 'rb') as file:
      pdf = PdfFileReader(file)
  
  page = pdf.getPage(1)
  #print(dir(page))
  print(page.extractText())
  </code></pre>
  
  <p>This gives me the error</p>
  
  <pre><code>ValueError: seek of closed file
  </code></pre>
  
  <p>I just put the code under the <code>with</code> statement, and it works fine. My question is: why is this so? I have already stored the information in 'pdf' object so i should be able to access it outside the  block.</p>