in printf, use ferror macro rather than directly inspecting flags bit