It is also built on the assumption that filenames never contain newlines, which is wrong in general.
It's baffling to me that POSIX allows non-printable characters in file names, but here we are. Surely they had a reason for this decision.