complete writefile