Typical way of creating a CSV string (pseudocode):
You could instead add the comma as the first thing inside your foreach.
if (sb.Length > 0) sb.Append(",");