def write_gauss(file_name, atoms, points, temp_name, proj_name='gaussian'):
    """
    Write a Gaussian input file.

    A template file needs to be prepared which has the name as XXX__NAME__XXX,
    the positions as XXX__POS__XXX and the (optional) charges as
    XXX__CHARGES__XXX.

    Parameters
    ----------
    file_name : str
        Name of the Gaussian input file to be written
    atoms : list of Atom objects
        Atoms to be calculated with Gaussian
    points : list of Atom objects or None
        The Atom objects should have a charge. If there is no XXX__CHARGES__XXX
        in the template file, this doesn't matter and can be None
    temp_name : str
        Name of the template file
    proj_name : str
        Project name, default 'gaussian'

    """
    with open(temp_name) as temp_file:
        temp_content = temp_file.readlines()
    out_file = open(file_name, 'w')
    for line in temp_content:
        if 'XXX__NAME__XXX' in line:
            out_file.write(line.replace('XXX__NAME__XXX', proj_name))
        elif 'XXX__POS__XXX' in line:
            for atom in atoms:
                atomStr = '{:>6} {:10.6f} {:10.6f} {:10.6f}'.format(atom.
                    elem, atom.x, atom.y, atom.z) + '\n'
                out_file.write(atomStr)
        elif 'XXX__CHARGES__XXX' in line:
            for point in points:
                point_str = '{:10.6f} {:10.6f} {:10.6f} {:10.6f}'.format(point
                    .x, point.y, point.z, point.q) + '\n'
                out_file.write(point_str)
        else:
            out_file.write(line)
    out_file.close()
    return
