in reply to Re^3: Invalid buffer?
in thread Invalid buffer?

I get the same "invalid output or indicator buffer" message on the last line of your code.