Moved all output functionality to separate file.
Restructured the manner in which responses are written to disk.