Updated program to use stdout