-Moved the file-writing stuff out from Elements into Main