Deleted extra outputIndex++ in writeToOutput(), and added comment explaining purpose of pointer *i.
Deleted extra outputIndex++ in writeToOutput(), and added comment explaining purpose of pointer *i.