Not meaning to hijack this thread, but there are side issues which have nothing to do with how your program is misbehaving, but you might want to attend to them eventually. You may even wish to take care of them now, on the theory that if you're seeking explanation for a big misbehavior, it's always good to clean up the little ones first, just to make the general picture a little simpler.
- To comply with standards, you'll want to put <CR><LF>, not just <LF>, at the end of every header line.
- To make your test more canonical in a couple of ways, you may wish to stick <LF> after "world!".
- Make your return code explicit.
int main(int argc, char **argv)