> while (has_watermark(text)) slightly_rewrite...
I understand what you are trying to say but I am not sure any watermark detection API would definitively return a true/false answer, I would have expected something more like a numeric confidence value. I am also not sure if the API would be deterministic.
I'm not sure how that changes the question -- just add `has_watermark(text) < 0.5`.