dashutil: improve end detection and error reporting