Program to Read and write into a file

# Writing
with open("sample.txt", "w") as file:
    file.write("Hello, this is a sample file.\nWelcome to file handling in Python!")
# Reading
with open("sample.txt", "r") as file:
    print("File Content:\n" + file.read())