Working on replacing fprintf with putc to keep null terminators out of the output