Replace stdout handling