added fflush before fork().