This is not an error message. It actually means the script ran successfully
and ended without returning a value (as it should).
Are you seeing that it failed in any other way except for this text?
It's not actually flattening the image. Text comments are still editable.
The method is working fine in Acrobat XI and I've never seen a bug report about it.
Flattening the document will convert comments/markup/form fields into page content, but any text is of course editable using the tools in Acrobat XI.
What do you mean by "text comments", exactly? If you mean text added by
using the Add Text & Images tool, then no, this function will not affect
them, as they are not located in an annotation or a form field.