def writeXYZ(data, filename, header=None):
    """ writes 3D coords of point to file. Each line contains the x, y,
    and z coords of a point. Optional head in the 1st line
    """
    fOut = open(filename, 'w')
    if header:
        fOut.write(header + '\n')
    for d in data:
        fOut.write('%(x)10.6f\t%(y)10.6f\t%(z)10.6f\n' % {'x': d[0], 'y': d
            [1], 'z': d[2]})
    fOut.close()
    return 1
