Made terminal_output use stdout and flush
Changed printf to terminal_output