Fix error code for WRITE array write failures

Should return -1 if any item in an array fails to write.