in reply to trapping overflows

If your input is a binary file, why are you reading it line-by-line?