Fixes #4: don't generate comma after last element in array