fixing output read/write mechanism.