I'll report back here as soon as I can make out a reproducible pattern.
I now believe this has to do with the "Strip trailing spaces and tabs" setting (Preferences > Files > Saving files); while the editor still displays the blank line, it is being stripped when the file is saved. That doesn't explain the perceived (imagined?) randomness though...