Actually write the file to the right directory