First, have you looked at the couple of questions on the Q&A already about exporting?
A few other pointers:
1) Your file name should end with ".csv" instead of ".txt", but yes it is plain text on the inside.
2) Export to CSV is a totally separate operation from the load/save project (using JSON). You'll want to make your own method inside the ProjectData class to handle exporting to the CSV file.