cat
gibt bei Erfolg 0 (Null) zurück.
Laut ssh
Handbuch:
STATUS BEENDEN
ssh exits with the exit status of the remote command or with 255 if an error occurred.
In Ihrem Fall reicht es also
cat some_lines_to_append.txt | ssh user@example.com 'cat >> all_lines_collected.txt' && rm some_lines_to_append.txt || echo 'Error occurred.'