When you do
ssh host$i "top -n1 -b | head -n 15>> ~/mysh/top_out"
you write the output to ~/mysh/top_out to the remote host, and not to the local computer. The remote host may not use the same physical home directory as your local computer. If you have NFS or something sharing your home directory on some machines, but not all, then you will see the symptoms you described.
Try to do
ssh host$i "top -n1 -b | head -n 15" >> ~/mysh/top_out
instead, or make things a little cleaner, maybe even
#!/bin/bash for i in $(seq 1 8); do (echo "host$i" ssh host$i "top -n1 -b | head -n 15") >> ~/mysh/top_out echo "done host$i" done
source share