`.load` ignores last line of file when it doesn't include a newline.

Version

v19.8.1

Platform

Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112 arm64

Subsystem

repl

What steps will reproduce the bug?

$ node
> fs.writeFileSync('foo.js', '{\n}')
undefined
> .load foo.js
{

...

(To be clear, it prompts for more text, it doesn't loop forever.)

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

What do you see instead?

(To be clear, it prompts for more text, it doesn't loop forever.)

Additional information

This seems related to #46731.