Hi all!

I have several text lines each one needs to be OpenSSL encrypted with the command

HTML Code:
openssl.exe rsautl -encrypt -in cf.txt -out cf.enc -inkey XXXXXX.cer -certin -pkcs
then, the output converted to base64 with the command

HTML Code:
=openssl.exe base64 -base64 -A -in cf.enc -out cf64.txt
To do this, I've created an excel file where I put each text line in each excel worksheet line, then created a Macro to encrypt, base64 conversion, and write the final output in the cell next to the original text line.

The problem is that it works, but randomly after 25-30 conversion, it skips a line, so, at the end, I have e new column with some blank cells. I'm on Windows 7. Tried also with Windows 10. Could you help me understand why and/or how to fix it? Here's the macro code (only for the first 100 lines):




HTML Code:
Sub scriviCF64()
ultima = 0
For i = 2 To 100000
If Cells(i, 2) = "" Then 
    If Cells(i + 1, 2) = "" Then ultima = i - 1
End If
Next i

For i = 2 To 101 'ultima
cf = Cells(i, 2).Value
Open "cf.txt" For Output As #1
Print #1, cf;
Close #1

Open "cf.txt" For Input As #3
Input #3, cf
Close #3

Application.Wait (Now + TimeValue("0:00:01") / (1000 / 1000))
retVal = Shell("openssl.exe rsautl -encrypt -in cf.txt -out cf.enc -inkey XXXXXX.cer -certin -pkcs")
Application.Wait (Now + TimeValue("0:00:01") / (1000 / 1000))
retVal = Shell("openssl.exe base64 -base64 -A -in cf.enc -out cf64.txt")
Open "cf64.txt" For Input As #2
Input #2, cf64
Close #2 
Cells(i, 16).Value = cf64
Application.Wait (Now + TimeValue("0:00:01") / (1000 / 1000))
Next i 

End Sub
I've added the Application.Wait because without those, the code would write the same string in all the lines. I thought it was a problem in creating cf.txt file, encrypting it to cf.enc and coding in base64. So adding the application.wait worked. But, randomly, after 20-30 correct coding, it skips a line and so on...

Could you help me understand why and/or how to fix it? the line skipping? Or, could you suggest an alternative method on how to batch openssl convert multiple text line at once? Thanks