Output optimization: use string::append

string::insert does not have char pointer specializations in libc++, and
clang does not replace the inner loop with memmove.
Besides, append() is nicer.