Emacs can edit remote files transparently (as if they were local).
Whenever Emacs asks for a file, you can indicate a remote file like so: /myname@remotehost:/remote/path/to/file. Emacs retrieves the file over SSH, FTP, or another method and takes care of saving it when you're done.
Emacs can record macros and execute them over a region.
use C-x-( to start recording
use C-x-) to end recording
use <esc>-x -> apply-macro-to-region-lines