Off-by-one error. Strange that it has not been noticed before.