The java.io.EOFException: Unexpected end of ZLIB input stream error indicates that the ZLIB decompressor is expecting more data than is available—in other words, the file is incomplete or corrupted at the time of reading. And as you mentioned, this happens randomly, which suggests a problem during writing.
If you read the file immediately after writing it, the system may not have finished flushing it to disk yet.
Checks that the write operation is complete.
Adds a Sleep(100) or confirmation after File.WriteBytes.
Use File.Exists and check the size