Move loop into bash so we stop on fail