Use SaveFileDialog.FilterIndex to set the string separator

If the FilterIndex is equal to 2, the separator used is '\t', this
replaces using a comparison with the file extension
Remove the last comma or tab from each line

Writes out one line at a time instead of writing all the string at once.
Removes the last comma or tab from each line