Added reading and writing to both server and client