The above code is a script which asks for stdin, and passes it through to a program expecting stdin. Why does the read happen after the command? Why not capture stdin first, then invoke the command with what's captured? If I wanted to run 'somecommand' several times in a loop, generating each input rather than reading it from the user, what would that look like?