Added writer to file.
Added the pretty formatter, cleaned up code and added comments.