Moved write_sum_head() here from generator.c.