<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def printUniqueTFAM(tfam, samples, prefix):
 """Prints a new TFAM with only unique samples. :param tfam: a representation of a TFAM file. :param samples: the position of the samples :param prefix: the prefix of the output file name :type tfam: list :type samples: dict :type prefix: str """

    fileName = prefix + ".unique_samples.tfam"
    try:
        with open(fileName, "w") as outputFile:
            for i in sorted(samples.values()):
                print >>outputFile, "\t".join(tfam[i])
    except IOError:
        msg = "%(fileName)s: no such file"
        raise ProgramError(msg)