There is no need to write the interim file, try:
oldtext = open("BATCH_ROLLBACK.txt").read()
oldtext = oldtext.replace('pyt_batch_id', '123456')
newtext = oldtext.replace('123456', 'pyt_batch_id',1)
f2 = open('NEWBATCH_ROLLBACK.txt', 'w')
f2.write(newtext)
f2.close()