>> Need to close stdout otherwise it can't be used in a script until surf
>> finishes. > > Am I missing something? Why not just use flose(stdout)? Using only fclose would result in Bad file descriptor errors on future attempts to write to stdout. freopen is cleaner.