Arduino Serial Writing Array Problem I am trying to communicate Pc - Arduino Uno.

My Arduino code is here: (It is working as below)

int ndx = 0;
char pack[12];            
void setup() {
Serial.begin(9600);
while(!Serial){;}
}

  void loop() { 

   while(Serial.available() ){  
    char rb = Serial.read();
    pack[ndx] = rb;
    ndx++;
    Serial.write(rb);
    if(ndx == 12){ 
        ndx=0;
      }     
    }
    }


If I try in 

Serial.write(rb);


Like that:

Serial.write(pack[ndx]);


Program is acting weird, I mean sending weird bytes. I do not know what is the reason. Can you help me, please? What is going on in code?
My python code:
https://github.com/mucahitkayadan/Python
you replace Serial.write(rb); to Serial.write(pack[ndx]); and get?:

char rb = Serial.read();
pack[ndx] = rb;
ndx++;
Serial.write(pack[ndx]);


then you read an uninitialized array item on the next index