check for err != nil before checking for short read