def listToFile(inList, fileName, extension=None):
    """Converts a list of file names into a file that can be used in iraf with the @ syntax.
    
    Returns the file name of the list file, with @ prefix added already.
    
    """
    listFile = open(fileName, 'w')
    for inFile in inList:
        if extension == None:
            listFile.write(inFile + '\n')
        else:
            listFile.write(inFile + extension + '\n')
    listFile.close()
    return '@' + fileName
