fix error adding trailing newline to sprintf