It is no longer possible to save a non-media file (e.g. data.txt) in the root dir of the external storage on Android 11+. You MUST use one of the Shared folders (/Documents or /Download) or save it in the ASD.
There are a lot of topics related to this. See also here:
He must set DefaultFileScope to Legacy in any case (Android version). (Of course this is a bug on Android 11+ as I mentioned countless times.)