Can't sign a certificate from script

Hello,

I’m writing a script with which I want to set HTTPS service up.
This script is copied to my 6.48 CCR1009 box through an scp command and then executed throuh a RouterOS /import.
Everything seems to working fine except for the last two statements.

These statements are:

/certificate sign  myrootcert
/certificate add name=mytlscert common-name=MyTik days-valid=5000
/certificate sign ca=myrootcert  mytlscert
/ip service set www-ssl certificate=mytlscert disabled=no port=21180

When I copy paste, these statements into a RouterOS terminal, they work fine.
I can understand why the last staetement fails if the previous one fails, but what shall I change to successfully run the whole thing ?

Best regards