<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_zmat(self, buf=None, upper_triangle=True, implicit_index=True, float_format='{:.6f}'.format, overwrite=True, header=False):
 """Write zmat-file Args: buf (str):
 StringIO-like, optional buffer to write to implicit_index (bool):
 If implicit_index is set, the zmat indexing is changed to ``range(1, len(self) + 1)``. Using :meth:`~chemcoord.Zmat.change_numbering` Besides the index is omitted while writing which means, that the index is given implicitly by the row number. float_format (one-parameter function):
 Formatter function to apply to column’s elements if they are floats. The result of this function must be a unicode string. overwrite (bool):
 May overwrite existing files. Returns: formatted : string (or unicode, depending on data and options) """

        out = self.copy()
        if implicit_index:
            out = out.change_numbering(new_index=range(1, len(self) + 1))
        if not upper_triangle:
            out = out._remove_upper_triangle()

        output = out.to_string(index=(not implicit_index),
                               float_format=float_format, header=header)

        if buf is not None:
            if overwrite:
                with open(buf, mode='w') as f:
                    f.write(output)
            else:
                with open(buf, mode='x') as f:
                    f.write(output)
        else:
            return output