diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php
index 62b2ad9d9afa1f64c90e15fa9851f7d92f575d70..3e8c3a912dade0c2c1f1241908ad37c6983f8063 100644
--- a/lib/private/files/stream/encryption.php
+++ b/lib/private/files/stream/encryption.php
@@ -205,6 +205,8 @@ class Encryption extends Wrapper {
 		$this->loadContext('ocencryption');
 
 		$this->position = 0;
+		$this->cache = '';
+		$this->writeFlag = false;
 		$this->unencryptedBlockSize = $this->encryptionModule->getUnencryptedBlockSize();
 
 		if (