Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection.
I used all the ways for the redirection of the output of c binary to a file, still it is failing.
Here are the different ways which I have used:

./a.out | tee -a /root/tmp.txt 2>&1
./a.out | tee -a /root/tmp.txt 1>&1
./a.out | tee -a /root/tmp.txt 2>&1 &
./a.out > /root/tmp.txt 2>&1 &

The issue which I am facing is, this was not redirecting any output to tmp.txt until it reaches some 100 lines number, once those many lines were reached it is dumping all the output to the file. And here also during this dumping I am loosing some 20 lines.
Any help is greatly appreciated.:mad:

If you want it in the file and in your stdout:

./a.out 2>&1 |tee -a test

Only in the file:

./a.out 2>&1 >test

If a.out is a long running program and you want to see the output immediately when written, it may be because you're using buffered output from the STDIO package writing functions (e.g., printf(), putchar(), and fwrite()). If that is your problem, you need to modify your C program to unbuffered or line-buffered output instead of fully buffered output. Check out you setbuf() and setvbuf() man pages.