Fixed array dimension issue when writing