Final lines of script dissapearing

I have started encountering a strange problem recently.
When I opened one of my R scripts, the last lines of the script had dissapeared. When I closed the script and opened it again in a different session, the lines were back. Next session, the lines were gone again. When I opened the script in Notepad, the lines were back again.
Now the same thing is happening with a RMarkdown file. Any idea what is going on here?

What are your encoding settings in Tools > Global Options > Code > Saving?

New complication: when I type Alt + Ctrl + R in the Rmd file with the "missing end", nothing at all happens.

There was, I've forgotten where of course, a thread a while ago about a similar problem that appeared to be caused by a text encoding of a .R file that was not the same as the system setting. Could it be something like that?

I don't see anything there. When I do "save with encoding", I just get the system default.