   getKeyCode();
   //if the key is good go through this
   if(keyStatus=="ok"){
-      byte i;
+      int i;
       //For CSH iButtons there are 7 code segments in hexidecimal 
-      for( i = 7; i > 0; i--) {
+      for( i = 7; i >= 0; i--) {
         
         //Adds leading zeros to hex if only one character long
         if( addr[i] < 0x10){ 


//iButton Variables
OneWire  ds(7);
byte addr[7];
int but[6] = {0,149,107,48,13,0};
String keyStatus = "";


       Serial.print(addr[i], HEX);
       
      }
      
       //Keep a delay so that it doesn't mistakenly read the same iButton more than once
      delay(1000);
      //Makes a new line
      Serial.println();
      
  }
  else if (keyStatus!="") {
    Serial.print(keyStatus);
  }
  }

//This does a lot of weird stuff about seeing if the data in the iButton is worth getting
void getKeyCode(){
