writeArray and readArray IO methods