seperated writefile and encrypt