Write Contour Results to a Text File

Goal: For a solved result, write the nodal/elemental values to a text file using PlotData.

Code:

Model=ExtAPI.DataModel.Project.Model
#select the result object on the tree
result=Tree.FirstActiveObject
resultValues= result.PlotData["Values"]
nodeList=result.PlotData["Node"]
with open('C:\Users\Admin\Desktop\Testfile.txt','w') as testfile:
    for ii in range(len(nodeList)):
        a=nodeList[ii]
        b=resultValues[ii]
        wrt=str(ii)+'\t'+str(a)+"\t"+str(b)+"\n"
        testfile.write(wrt)