Note, I'm using bash, not csh, because I don't hate myself. But you can do all this in csh, you'd just have to translate. If you want to work in bash instead, simply run "bash --login" first and then you're working in bash.
To do the sort of task you describe in a shell script, we use pipes and not loops like you would in a programming language. Don't get me wrong, there are looping structures in csh and bash, but for what you've described, we do it differently.
If I had a command that produces multiple lines of output and I wanted those lines to be acted on one at a time by another command, I'd connect the two commands with a pipe | , like this maybe:
cat file.txt | grep "some words"
The grep command processes each line coming in from STDIN, which is linked by the pipe to STDOUT of the cat command. This is a trivial example, but it serves.
another:
echo 'one,two,three' | tr ',' '\n'
That will replace all the commas with newlines, creating a three line output from the one line input.
If I wanted to add an extension to the names of all files in a directory, I might do something like this:
cd directory
for filename in *
do
mv ${filename} ${filename}.extension
done
The * is file globbing pattern. File globbing is when a pattern on the command line is replaced with any filename in the current directory that matches the globbing pattern. The * means "anything"