title: PyCryptoDome cipher.encrypt saving blank text to encrypted file
body: <p>I am having much trouble encrypting the contents of the file at path accountfile.
  The encryption does indeed work, as the decryption successfully output the path of accountfile of a version where the path was being saved to the file. The code runs successfully without errors, but the encrypted file that is saved ends up being blank when encrypted. How do I get the contents of ptext to be successfully encrypted?</p>
  <pre><code>def encrypt_account(path, filename, accountfile):
      c_file = PurePath(path).parent / (PurePath(filename).parent.name + &quot;c.txt&quot;)
      file3 = open(c_file, 'rb')
      byteskey = file3.read(32)
      file3.close()
      ckey = bytes(byteskey)
  
      cipher = AES.new(ckey, AES.MODE_CBC)
      ptext = open(str(accountfile)).read()# this is the account file
      ciphertext = cipher.encrypt(pad(bytes(ptext, &quot;utf-8&quot;), AES.block_size))
  
      with open(str(path.parent / accountfile.stem) + &quot;.enc&quot;, 'wb')as c_file:
          c_file.write(cipher.iv)
          c_file.write(ciphertext)
      #c_file.close()
      #os.remove(accountfile)
  </code></pre>