Well I've not tested your code but from what I can see I don't think it's actually writing to a text file. You have a space between $gettok(%z,6,32) .txt.

So maybe $+($gettok(%z,6,32),.txt)

Also, you mentioned %zz variables issue solved so do you mean $+($gettok(%zz,6,32),.txt)

All the best,

-Andy