ensure loop is drained
add read error handler