human
fwrite string to file.
assistant
Here is a Python function to write string to file

import os

def fwrite(file, data, mode='w'):
    """
    Write data to a file.

    :param file: The file object.
    :param data: The data to write.
    :param mode: The mode to open the file.
    """
    file.write(data)

# Enter the file name
file_name = "test.txt"

# Enter the data
data = "This is a test"

# Calling the function
print((fwrite(open(file_name, 'w'), data)))

#Example Output
# None

#Remember to inspect code for bugs.