Finished file writing

Very crude solution, leaves rooms for hacker exploits