def main(line_no): delta = 30 with open('temp/not_well_formed2.xml', 'r') as frh: res = frh.read() print(res[line_no - delta:line_no + delta]) if __name__ == '__main__': main(490150)