Printing SD card file contents on LCD This is a part of my program which reads data from file stored in SD card and displays that on an LCD screen.

  File dataFile = SD.open("1165.txt");


  if (dataFile) {
    Serial.println("File Opened");
    lcd.clear();
       delay( 5 );  //LCD-specific M
       lcd.setCursor( 0,0 );


  while (dataFile.available()) {
      Serial.write(dataFile.read());
      lcd.write(dataFile.read());
      lcd.print(dataFile.read());
    }
  dataFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error");
  }


When I look at the serial monitor it prints the contents of that file but none of these commands print what is printed in the serial monitor,

lcd.write(dataFile.read());
lcd.print(dataFile.read());


Any ideas?
When you call dataFile.read(), the file pointer is advanced, so you always read different bytes in each read call. Imagine the file like a book with many lines: Each time you read, you advance the current line, so with multiple calls, you never get the same data. The solution is to currently store the last read byte:

while (dataFile.available()) {
  char readByte = dataFile.read();
  Serial.write(readByte);
  lcd.write(readByte);
  lcd.print(readByte);
}


You have two calls for displaying data in the LCD, but be careful that the second call (print) might interpret your data as a number, so just remove the lcd.print(readByte) call altogether to be sure it's printing the raw character.