import sys
import os  

# Save original stdout
original_stdout = sys.stdout

# Create a class to duplicate output
class Logger:
    def __init__(self, filename):
        self.terminal = original_stdout
        self.log = open(filename, 'w')
        
    def write(self, message):
        self.terminal.write(message)
        self.log.write(message)
        
    def flush(self):
        self.terminal.flush()
        self.log.flush()