Refactor: introduce method that creates the csv string and writes headers.
Refactor: create cleanUpLastRow method that deals with trailing delimiters.
Refactor: introduce a method that deals with adding newline character.