Fixed 3 bugs in fprintf