How to stop reading from standard input?

Right now if I pipe something to a script that uses the read builtin, Ion will read from standard input line by line until the last line, then instead of returning some end of input character read will just keep returning the last value. This means if I try to capture standard input with a while loop it will just go forever:

while read line
        # do something

I think ideally the read builtin would return false as soon as it reached the end of the input and the code would work just as it’s written.

I managed to work around this by adding the following code to the beginning of the while loop:

if eq $last_line $line
        let last_line = $line

This will of course break if there are repeated lines in the input.