read error correctly