File Reader/Writer in Python

Below is an example of how you can use Python's open function to read from and write to a file.

import os

input_file = "input.txt"
output_file = "output.txt"

# Reading from a file using open and read
with open(input_file, "r") as file_reader:
    content = file_reader.read()
    print("Read from file:", content)

    # You can process the content as needed here

# Writing to a file using open and write
with open(output_file, "w") as file_writer:
    # Replace the following line with the content you want to write
    content_to_write = "Hello, this is written to the file!"
    file_writer.write(content_to_write)

    print("Write to file:", content_to_write)