Since no language was specified this is written in python. The program will save an input and then check if the input is empty. If the input is empty, that means Enter was pressed. After it gets the input it will check if filename is anything other than empty input (which is Enter key). If the input contains something then it opens the file in write mode, or creates it if it doesn't exist, then writes to the file (since an output wasn't specified I put OUTPUT as example). If the input is empty, meaning the Enter key was pressed, then the program won't do anything with it.
# if Enter is pressed than the input will just be an empty string
filename = input("Enter an output filename (or press Enter to quit): ")
# this checks if the filename is equal to anything other than empty string, meaning not Enter key