with open('file2.conf','r+') as f: try: #f.seek(210) #conts=f.read(80) f.seek(292) #print(f.tell()) f.write('YYYYYYYYYYYYYYYYYYYY\n') conts=f.read(80) print(conts) except RuntimeError as e: print(e)