ruby open file and append

# Step 1: Open a file in append mode
file_path = 'example.txt'
file = File.open(file_path, 'a')

# Step 2: Write content to the file
content_to_append = "This is the content to append."
file.puts(content_to_append)

# Step 3: Close the file to save changes
file.close