hw-2: added write to file and stdout