The line `print('.', end="", flush=True)` causes a TypeError `extra keyword arguments given` The example works without this line.