[TASK] Write to file directly

Save some costly memory by writing to the file directly instead of
keeping the whole file in memory.
[FEATURE] Report peak memory usage and end with a newline
[FEATURE] Add support for escaped class names