Issue #18912: Fix indentation in docstring

Contributed by Jeroen Van Goey
cwr_next():  move invariants out of loops.

This simplifies and clarifies the code, and gives a small speedup.