changin output file name

I'm trying to write a program for class (yes, I'm just learning programming) and I need to get a string input, then produce an output text file with that name. I know how to write output to text files, but I can't figure out how I can get the value of a string variable to be the name of the text file, therefore producing a new file each time a new name is entered. The problem for me is the fact that the filename is in double quotes "example.txt", so I can't substitute the variable name in. Any help is appreciated. Thanks.