.R file content deleted after saving

Hello everyone! I was hoping someone could help me with quite a strange issue I have been experiencing lately. I was working on some code for a shiny app in a .R file. I ran the code a couple of times and it worked fine. After saving my app, I then attempted to use another R session to run it using the runApp function, but I got back an error saying that the function "did not return a shiny.appobj object" . Upon opening my app again (the .R file), I realized that not only was all the content gone, but the size of the file was 0 KB. I read online that this could potentially be linked to issues with cloud storage sync services such as One Drive, which I have. I tried again by changing my directory to a local folder, and the issue persisted.

Even more strangely, I created another .R file just for testing. Once again I could perfectly run the code in the session, so I hit save and logged out. After opening it once more, all the content was gone; however, this time the size was 5 KB. I have tried changing the directory to multiple locations in my local storage but the issue persists. I read this issue was common in earlier versions of R and was presumably fixed way back ( RStudio 2022.02.3+492). I do not know if someone else is experiencing the same issue with RStudio or if it could also have something to do with my own system. I would appreciate any advice on how to solve this. I'm currently working on a Windows 10 laptop and I have the latest version of RStudio installed. Thank you so much beforehand.