Appending authorized_keys on multiple servers using ssh

Hi

I have an ssh 'for' loop script to login and put a key on multiple servers. I need to append a file on each server but the command which works ok from the prompt does not work via the script. I have

cat filename | ssh user@servername "cat >>append.file.name"

I have tried to 'spawn' this in the ssh loop script but it doesn't work - It cats the contents of filename then issues lots of messages regarding

'ssh not found'
'cat not found'

etc

spawn cat KEYNAME | ssh $hosty "cat >>/serv/me/.ssh/authorized_keys"

Any help much appreciated

Cheers