Made changes after code review - put StringWriter in a using and change to using the StringWriter.ToString function instead of the StringBuilder.ToString function