Hi Jum, Using $| = 1; and autoflush is correct, but if you're calling subprocesses or output is redirected, buffering may still happen. Make sure the script runs in a terminal, and consider disabling buffering in the subprocess (e.g., using stdbuf on Unix). Also, check if manual flushing after each output is needed.
$| = 1;
autoflush
stdbuf