Use nprintf instead of direct appending