Capacitor's Filesystem.writeFile fails unless I specify encoding on iOS

We are creating an application in which there is a functionality where we have to download the file to the iOS application’s document directory.
We are using the capacitor’s filesystem plugin to write the file but we are facing an issue with that.
Filesystem.write is failing on iOS if I do not use the encoding parameter. It is giving an error that the file could not be saved.
And if I use Encoding.UTF8 then the file gets corrupted and does not open.

I was not getting this issue in Capacitor v2. I have been getting issue in Capacitor v4.

I am struggling to get past this error and wondering if anyone can help.

Thank you.