Write the .geo file

def write_geo_file(self, filename):
        """
        Write the .geo file
        """
        fid = open(filename, 'w')
        # 2D mesh algorithm (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal,
        # 7=bamg, 8=delquad)
        # according to the GMSH-mailing list the frontal algorithm should be
        # one of the best in terms of grid quality
        fid.write('Mesh.Algorithm = 6;\n')

        self.write_points(fid)
        self.write_lines(fid)

        # fid.write('Coherence;\n')
        # write line loop
        fid.write('Line Loop(1) = {')
        fid.write(','.join(['{0}'.format(x) for x in self.BoundaryIndices]))
        # for i in self.BoundaryIndices:
        #     fid.write('{0},'.format(i))
        fid.write('};\n')
        # # fid.write('{0}}};\n'.format(len(self.Lines)))
        fid.write('Plane Surface(7) = {1};\n')

        self.write_in_plane_nodes(fid)
        # fid.write('Coherence;\n')
        self.write_extra_nodes(fid)
        # fid.write('Coherence;\n')
        for index in self.ExtraLineIndices:
            fid.write('Line {' + '{0}'.format(index) + '} In Surface {7};\n')

        # Lloyd mesh optimisation crashes
        # fid.write('Mesh.Lloyd = 1;\n')

        # run the mesher
        fid.write('Mesh 7;')

        if os.path.isfile('../gmsh_commands.dat'):
            fid2 = open('../gmsh_commands.dat', 'r')
            additional_commands = fid2.read()
            fid2.close()

            fid.write('\n')
            fid.write(additional_commands)

        fid.close()