can now write files

Now able to write files, requires refactor once merged.