read(1) returns b'' on EOF, which wasn't checked for in a couple cases, which could cause empty/truncated input to enter one of the `while True` loops without hope of exit. programming is hard.