Put comment lines after header for io.ascii commented header writing

This is a continuation of #3222; I finished the comment writing code and switched the order of the header and commented lines for commented-header format.
@taldcroft, @hamogu - is this okay?