Fix wrong handling of grep output