Updated file-writing