As mentioned by @tjluoma, this is easily done using the KM For Each action with either a Folder Contents collection or a Finders Selection collection.
KM even has a Append Text to a File action.
That will make it easier to maintain and expand on, without having to have a detailed knowledge of shell scripting. It is also safer.
There are several good Macro examples in the Forum's Best Macro List , as well as in the forum in general. Do a forum search on "files".
Please let us know if you have any further questions.