Your counter problem ($orphCount = -1) is here
Code:

For Each $VarNameA in $dictAllVars.Keys
$VarCount = $VarCount + 1
$VarString = $VarString + $VarNameA + ","
Next
$varArray = combsort (Split ($VarString,","))


first you build a string that always ends with a comma
then you split it with comma as delimiter
the last element in your array is ""
after combsort it is shifted to the first place
better would be something like:
Code:

For Each $VarNameA In $dictAllVars.Keys
$VarCount = $VarCount + 1
If $VarString
$VarString = $VarString + ","
EndIf
$VarString = $VarString + $VarNameA
Next
$varArray = combsort (Split ($VarString,","))


Have you allready changed the substr thing I was talking about?
Code:

;For $c = 0 to Len($Line) <-- This is wrong
For $c = 1 to Len($Line)
$Char = SubStr($Line, $c, 1)