Oh, It looks sooooo strangs, but when redirecting output to a terminal, stdout is buffered line by line -- that is, once you do a putchar('\n') or equivalent,the buffer is written to standard output with a "write(1, ...)". However, when stdout is redirected to a file, the stdio library buffers on a coarser scale -- not writing until some large buffer (probably 4K or 8K characters) is full. Thus, at the time of the fork() call, the "hello" string has not been written to fd=1. Instead, it has been buffered in the standard I/O library. That buffer is part of the program's address space, and is thus copied to the child process when fork() is called. Thus, when the bytes are finally flushed from the buffer, the "hello" string is written to the file twice. This is an important thing to realize. It looks strange but has a logical explanation.
See
http://www.cs.utk.edu/~plank/pla ... s/Fork/lecture.html for details.
BTW, you can modify your program to following lines and ...

)
#include <stdio.h>
mian ()
{
printf("hello\n");
if ( fork() == 0 ) {
printf("world\n");
printf("hello again\n");
}