file=open("filename","r")
data=file.read()
with open("enter your file_name","r",encoding='UTF8') as title:
title=title.readlines()
file=open("filename","w")
file.write("Enter your data that needs to be written in the file")
with open("file_name", "w") as f:
f.write("data")