Revert "Remove the use of trim to remove final delimiter. We are removing and then adding it again anyway. #6840"

This reverts commit 40a109b71da5008f17c8709882e24f61721fba41.