The echo error is caused when there's a blank line or a line containing only spaces. You can either do checking to avoid echoing 'nothing', or have a prefix at the front of the echo.

echo -a %temp

would change to one of these:

echo -a >>: %temp
if ($remove(%temp,$chr(32)) != $null) echo -a %temp