read and write from console