How do I run a shell command in a while loop?

The command is:

sic -h irc.freenode.net 2>&1 | tee -a irc.log

Where sic is an IRC client, and I'm piping the output to tee in order to log my IRC sessions.

I'm trying to handle reconnects by running it in a while loop in the shell process and cat the initial commands into sic's stdin.

I would think to approach this by using a fifo (using the mkfifo(1) command) to redirect sic's stdin, but I'm not sure if there's a more elegant way to reconnect on ping timeouts, kills, servers going down, and just disconnects in general.

How do you suggest I go about doing this?

(I'm using OpenBSD's ksh if that matters.)

Take a look at man expect (linux) and man ksh (linux) coprocesses (examples here).