Save 40% of DAG generation time on Windows.

fputc() is not a good idea on the VS2012 CRT (slooooow)
Use a custom buffered writer instead.
Saves 5 seconds of DAG generation time on a big project.