It doesnt work.
Looks like the issue is on the call to shell command.
I pipe the command to "tee" then make a diff, and I get 6 lines that are not in the file.
Very strange, because if I execute the command directly from my shell, it works perfectly.