Thanks for the link Gazareth.
I have read the article and tried the -Verbose with both lines that did not produce the error.
In both instances of the output was into the shell window (was tested in the ISE), even when I used the pipelined out-file it failed to redirect the output to the file.
It seems from that article that there is not much else that can be tried.
I shall have to add a comment to the code to explain why I did not use Invoke-Sqlcmd as a reminder.
Still open to other suggestions though.