Post History
I would consider your own tools as the central use case. Seriously, do you want to litter every while read (or your language's equivalent) with this pesky corner case handling? while read -r line ...
Answer
#1: Initial revision
I would consider _your own tools_ as the central use case. Seriously, do you want to litter every `while read` (or your language's equivalent) with this pesky corner case handling? ``` while read -r line || [ -n "${line-}" ] do : something with "$line" done <"$input_file" ``` Having a single well-defined behavior also reduces the need for speculation. With malformed files, what exactly should `tail -n 1` return? Which line(s) should the `$` address in `sed` (which matches on the final line in well-formed files) match on? You might argue what you think the "obvious" answer to these questions should be, but since that's non-standard behavior, you can never rely on these constructs to work portably, and so you are needlessly restricting the usefulness of your scripts. As noted elsewhere, `cat` and `wc -l` on malformed files are another two use cases which commonly fail; but the vast bulk of broken tools will probably be local or informal tools which were never tested for this particular corner case.