data array from sdcard just reading the last index

i try to make automatic door lock based by time , and i get time from RTC, i have schedule for time on SD card Buka.txt …
this is data on buka.txt
9,10
11,12
13,14
15,16
17,18
(17 is time open door, 18 is time closed door sepparated by comma)

my problem is door just open and close on the last array index on 17,18
please help me, thanks .

syntax :

File file;
long x, y;
bool readLine(File &f, char* line, size_t maxLen) {
for (size_t n = 0; n < maxLen; n++) {
int c = f.read();
if ( c < 0 && n == 0) return false; // EOF
if (c < 0 || c == ‘\n’) {
line[n] = 0;
return true;
}
line[n] = c;
}
return false; // line too long
}

bool readVals(long* v1, long* v2) {
char line[40], *ptr, *str;
if (!readLine(file, line, sizeof(line))) {
return false; // EOF or too long
}
*v1 = strtol(line, &ptr, 10);
if (ptr == line) return false; // bad number if equal
while (*ptr) {
if (*ptr++ == ‘,’) break;
}
*v2 = strtol(ptr, &str, 10);
return str != ptr; // true if number found
}

void setup(){
lcd.begin (16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(LED_ON);

pinMode(10, OUTPUT);
pinMode(2, OUTPUT);
Serial.begin(9600);
if (!SD.begin(10)) {
Serial.println(“begin error”);
return;
}
file = SD.open(“Buka.txt”, FILE_READ);
if (!file) {
Serial.println(“open error”);
return;
}

}

void loop() {
tmElements_t tm;
lcd.backlight();
readVals(&x, &y);
int Buka =59;
int tutup=00;
RTC.read™ ;
lcd.setCursor(0,0);
lcd.print(“JAM :”);
print2digits(tm.Hour);
lcd.print(’:’);
print2digits(tm.Minute);
lcd.print(’:’);
print2digits(tm.Second);
long thehour = long(tm.Minute);

Serial.println("Jam buka: ");
Serial.println(x);
Serial.println("Menit tutup: ");
Serial.println(y);
Serial.println();

/while/
if (x==thehour){
digitalWrite(2,HIGH);
lcd.setCursor(0,1);
lcd.print("BUKA ");
//return;
}
if (y==thehour){
digitalWrite(2,LOW);
lcd.setCursor(0,1);
lcd.print("TUTUP ");
//return;
}

}

void print2digits(long number) {
if (number >= 0 && number < 10) {
lcd.print(‘0’);
}
lcd.print(number);
}

That is NOT how to post code. Read the stickies at the top of the forum to learn how to do it properly.

And stop creating new threads on the same problem. All that does is piss people off.