Fix output issue when first index has nil value