Updating CA root certs regularly

Following on this old post: http://forum.mikrotik.com/t/updating-ca-root-certs-regularly/144990/1

My version looks like this but generates the error every other run. I run it once, it fails (i.e. it writes the error to the log), run it again and it passes (i.e. it writes the success message to the log). If I manually enter the commands they work fine on their own. Any reason why it would fail 50% of the time?

{
  :do {
      /tool fetch url=https://pki.goog/roots.pem dst-path=roots-goog.pem;
      /certificate remove [ find where authority expired ];
      /certificate import file-name=roots-goog.pem passphrase="";
      /file remove roots-goog.pem;
      :log info ("Updated certificate trust store");
  } on-error={
      :log error ("Failed to update certificate trust store");
  };
}

remove frills, improve logics
{
:do {
/tool fetch url=“https://pki.goog/roots.pem” dst-path=“roots-goog.pem”
:delay 2s
/certificate
remove [find where authority expired]
import file-name=“roots-goog.pem” passphrase=“”
/file remove [find where name=“roots-goog.pem”]
:log info “Updated certificate trust store”
} on-error={
:log error “Failed to update certificate trust store”
}
}

Excellent, thanks!