updated write(*,*) statements to either use stderr or stdout