This was tricky to get working, so once I did, I wanted to share with everyone, in case anyone else could benefit.
So I added a button to my form that the user can click which will automatically create and download the CSV file. Here's how to do it.
By the way, this isn't supported by all browsers (for example - IE 11 doesn't support but Chrome 55 does) - the code will warn the end user if it isn't supported in their current browser and recommends them to try Chrome instead. For cross-compatibility, I had to leave the text field accessible to the user in addition to the button - so the button isn't a solution by itself, just an added feature.