It's a little tough to explain.
The module that I call deals with MIBs. If you've ever worked with MIBs you'll know that although there's a standard, it's often ignored, and you can end up in infinite loops (well, until your memory runs out).
The writer function gets called for each line of output from the module function. If it's looping indefinately, it's going to keep calling the writer function. I'm not sure if I can kill the entire output function from the referenced writer function. If I can, your solution may just work.