title: Decryption takes more memory and CPU when files are not encrypted
body: <p>I have a file encryption/decryption program that encrypts files from a given folder. So I encrypt files and, when decrypting, if the wrong password is given, it gives an error and doesn't consume lot of memory or CPU.</p>
  <p>However, when files are not encrypted and I try to decrypt the files, the program consumes 100% CPU and memory and throws an error of <code>Wrong password</code> (which is correct). But why des it consume so much memory and CPU?</p>
  <pre><code>def decfile(file):
  
      filePath, fileExtn = os.path.splitext(file)
      decFile = filePath+'dec'+fileExtn
  
      with open(file, 'rb') as decrypted_file:
          with open(decFile, 'wb') as original_file:
              
              nonce = decrypted_file.read(12)
              decrypted_file.seek(12)
  
              while True:
                  l_bytes = decrypted_file.read(encrypted_blockSize)
                  if not l_bytes:
                      break
  
                  l = int.from_bytes(l_bytes, 'big')
                  encrypted = decrypted_file.read(l)
  
                  decrypted = chacha.decrypt(nonce, encrypted, aad)
                  original_file.write(decrypted)
  
      decrypted_file.close()
      original_file.close()
  
      os.replace(decFile, file)
  </code></pre>
  <p>The above code is the decryption function.</p>
  <p>The below code is the <code>try ... except</code> block, which gives an error if the password is wrong.</p>
  <pre><code>try:
      with concurrent.futures.ThreadPoolExecutor() as executor:
          result = executor.map(decfile, fileList)
  
      list(result)
      
  except:
      print('Wrong Password')
  </code></pre>