This could cause an infinite (or effectively infinite) loop. I would retry a certain number of times. Add a CLI arg to set that number.