Add function to print to stdout in sync.