As part of collection_defragmentation.js, we are looking for merge commands that can be issued. However, the loop to search for these commands is broken.
The index used to check for contiguous chunks is never incremented, and the check for the next chunk being on the same shard as the current one could go out of bounds if the index is set to chunks.length - 1.