change write from echo to STDOUT