def METHOD_NAME(fname, polygons):
    with open(fname, 'rb') as fp:
        doc = etree.parse(fp)
        lines = doc.findall('.//{*}TextLine')
        idx = 0
        for line in lines:
            if line.get('BASELINE') is None:
                continue
            pol = line.find('./{*}Shape/{*}Polygon')
            if pol is not None:
                if polygons[idx] is not None:
                    pol.attrib['POINTS'] = ' '.join([str(coord) for pt in polygons[idx] for coord in pt])
                else:
                    pol.attrib['POINTS'] = ''
            idx += 1
        with open(splitext(fname)[0] + '_rewrite.xml', 'wb') as fp:
            doc.write(fp, encoding='UTF-8', xml_declaration=True)