Fixed off-by-one error in read/write of MPS