something wierd, only the second time that i run the script the function actually save the data in the txt file. what am i doing wrong? the m file is attached to this post
or maybe there is another solution for this, i'm trying to generate text file with the data taken from the workspace something similar to what there is in the script