add writefile method