R script suddenly becomes empty (0 KB)

I am just going to pull up at least three main posts that claim a problem that also happened to me, but which have not yet been useful for my problem (i: R script becomes empty (0KB) after saving, ii: R code file 0 kb after saving with previous version of R, and iii: R Code file is becoming 0 KB after saving . The R script files suddenly become empty (0 KB). I have tried installing different versions of R and RStudio, but nothing solved my problems, not even when I tried using a text editor. RHistory and .RData do not help either.
I have just lost a very important code. Any help is more than welcome.

What versions of R and RStudio are you running?

R.Version()
and
RStudio.Version()

will tell you.

Rstudio: 2024.12.0.456
R: 4.4.1

At least, for the time being, your operating system should provide you with a means to restore a previous version of the file, or restore a backup?
Using a private GIT repository might help too.

There is no previous version or backup available, unfortunately.

I'm guessing that perhaps your system is not using an English locale. Is it possible that you're not using UTF-8 encoding for text files?

I am using UTF-8 encoding.