title: Splitting PDF file into single pages using PyPDF2
body: <p>I'm trying to split a 3 page PDF into 3 separate PDF files. I have been trying to use the following code:</p>
  
  <pre><code>from PyPDF2 import PdfFileReader, PdfFileWriter
  
  pdf_file = open('Sample.pdf','rb')
  pdf_reader = PdfFileReader(pdf_file)
  pdf_writer = PdfFileWriter()
  
  
  pageNumbers = pdf_reader.getNumPages()
  
  for i in range (pageNumbers):
      pdf_writer.addPage(pdf_reader.getPage(i))
      split_motive = open('Sample_' + str(i+1) + '.pdf','wb')
      pdf_writer.write(split_motive)
      split_motive.close()
  
  pdf_file.close()
  </code></pre>
  
  <p>But that always seems to generate 3 PDF files: </p>
  
  <ol>
  <li>The first page of the source PDF</li>
  <li>The first and second page of the source PDF</li>
  <li>The first, second and third page of the source PDF</li>
  </ol>
  
  <p>Can anyone help?</p>