Open file and create if it doesn't exist

hey, I got an exercise, whice please me to open txt file (or create it if it doesn’t exist).
I got 2 Parameters: 1. txt_file. 2. list of tuples (word, count)
I have to over write the file, such that the final file will be:
evrey line will include tuple, like that:
apple, 1
dog, 2
etc.
I tried to do this thing:
def write_output_file(results, output_filename):

def write_output_file(results, output_filename):
    # open file in over mode
    f_output = open(output_filename, 'w+')
    for line in f_output:
        for result in results
            line = line.split("\n")
            print(line)
    f_output.close()

but I didn’t get desirable result.