added binary mode to all read and write