replaced read/write with scanf/printf