Writing output files

Now complete, plus started on the GUI