. Split appendf() calls into a number of append() calls. . To insert spaces, instead of sitting in a loop, use a spaces[] buffer and insert a chunk of it with appendl().