Can't get M808 (looping) to work

Hi,
I’m trying to loop a print job, but the (Marlin-compatible) M808 command isn’t working for me. The gcode file just runs once when I print it. I’ve tried directly using the SDCARD_LOOP_BEGIN / END commands as well, but those don’t work either.

Is anyone using this command? If so, can you show me how you set it up?

Here’s the little test gcode I tried:

M808 L10
G1 X50 Y50 Z50 F3000
G1 X60 Y60 Z50 F3000
M808

As per Klipper documentation, the following is in my printer.cfg file:

[virtual_sdcard]
 
path: ~/gcode_files
 
# SDCard 'looping' (aka Marlin M808 commands) support
#
# Support SDCard looping
[sdcard_loop]

# 'Marlin' style M808 compatibility macro for SDCard looping
[gcode_macro M808]
 gcode:
     {% if params.K is not defined and params.L is defined %}SDCARD_LOOP_BEGIN COUNT={params.L|int}{% endif %}
     {% if params.K is not defined and params.L is not defined %}SDCARD_LOOP_END{% endif %}
     {% if params.K is defined and params.L is not defined %}SDCARD_LOOP_DESIST{% endif %}

Solved. Adding a line after the last M808 command makes it work. Strangely, it still works if the lines after the loop are deleted.

February 2025: Edited for conciseness.
Note to self: Hey you, this is your own post, remember!