LCD programme problem

I'm making a programme where an LCD has 4 responses and pressing a switch cycles through them.
I found when I plugged the arduino in the initial message before the switch was pressed was fine. But when i pressed the switch the actual text on the LCD kept flashing and wouldn't stay solid. If the switch was pressed again it displayed the next message but it also wouldn't stay solid. This happened for all of the responses apart from the 4th. When the switch was pressed to change to the 4th response it wouldn't stay solid, but if the switch was pressed again it became solid. If the switch was pressed again after that it went back to the 1st response as it was supposed to, but it was still flashing.
This is the script:

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int counter = 0;
int prevSwitchState = 0;
int reply;
void setup(){
lcd.begin(16,2);
pinMode(switchPin,INPUT);
lcd.print("Press the button");
lcd.setCursor(0,1);
lcd.print("To begin!");
}
void loop(){
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState){
if (switchState == HIGH) {
counter = counter + 1;
}
if (counter == 5) {
counter = 0;
}
}
if (counter == 1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("1 blah blah");
lcd.setCursor(0,1);
lcd.print("1 blah blah");
}
if (counter == 2){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("2 blah blah");
lcd.setCursor(0,1);
lcd.print("2 blah blah");
}
if (counter == 3){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("3 blah blah");
lcd.setCursor(0,1);
lcd.print("3 blah blah");
}
if (counter == 4){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("4 blah blah");
lcd.setCursor(0,1);
lcd.print("4 blah blah");
}
prevSwitchState = switchState;
}

Any help or ideas as to the cause of the problem would be greatly appreciated.

Probably it will help to do the output only when a new key was detected

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 5, 4, 3, 2);
const int switchPin = 6;
int switchState = 0;
int counter = 0;
int prevSwitchState = 0;
int reply;
void setup() {
  lcd.begin(16, 2);
  pinMode(switchPin, INPUT);
  lcd.print("Press the button");
  lcd.setCursor(0, 1);
  lcd.print("To begin!");
}
void loop() {
  switchState = digitalRead(switchPin);
  if (switchState != prevSwitchState) {
    if (switchState == HIGH) {
      counter = counter + 1;
      if (counter == 5) {
        counter = 0;
      }
      if (counter == 1) {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("1 blah blah");
        lcd.setCursor(0, 1);
        lcd.print("1 blah blah");
      }
      if (counter == 2) {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("2 blah blah");
        lcd.setCursor(0, 1);
        lcd.print("2 blah blah");
      }
      if (counter == 3) {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("3 blah blah");
        lcd.setCursor(0, 1);
        lcd.print("3 blah blah");
      }
      if (counter == 4) {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("4 blah blah");
        lcd.setCursor(0, 1);
        lcd.print("4 blah blah");
      }
      prevSwitchState = switchState;
    }
  }
}

You should add debouncing code, depending on your button.

Thanks for replying.
I tried the changes you suggested and it solved the problem of the LCD blinking but it now doesn't respond if the switch is pressed a second time.
When I uploaded the programme it displayed the initial message without blinking. If i then pressed switch it displayed the first message without blinking. But after that pressing the switch did nothing.

Your code does not handle any bouncing of the key,
you will probably have to add some code.

How did you connect the key to the Arduino?

If done in a standard way (without external resistor and closing to GND)
you should use INPUT_PULLUP and change the logic to test for LOW if closed.

lcd.clear(); is like a sledge hammer. Its a great tool but it has to be used wisely especially on very short fast programs. By the time the info has been passed to the lcd the clear is probably already sent to wipe the display.

if the counter didn't change then the info being sent to the lcd didn't change so add something like above the counter "ifs".

if (counter != prevcounter){//data did not change
lcd.clear();
}

remove all the other lcd.clear(); from the counter "ifs"

and at the bottom put

prevcounter = counter;

now the lcd will only be cleared if the counter has changed and new info is being written

That's it all working perfectly now so thanks to everyone for helping!

I blinks because no matter what is happening with the switch, you always clear and rewrite the LCD.

It displays ok before you press the switch because at that stage, the counter is 0 and you don't have an action when that happens.

There might be a few ways to improve this beyond fixing it.

Every branch of the if is the same. Why not make it a function?

void lcdPrint2Lines(char *line1, char *line2) {
        lcd.setCursor(0, 0);
        lcd.print(line1);
        lcd.setCursor(0, 1);
        lcd.print(line2);
}

Why not use a switch statement instead of an if? it's more compact, and the compiler can optimise it better:

  switch(counter) {
    case 1: lcdPrint2Lines("case 1", "some text"); break;
    case 2: lcdPrint2Lines("case 2", "some other text"); break;
   // etc
  }

Or you can use an array of messages:

char *messages[][2] = {
  {"case0","initial text"},
  {"case1","some text"},
  {"case2","some more text"},
  // etc
};

void loop() {
  lcdPrint2Lines(messages[counter][0], messages[counter][1]); 
}

There's plenty of ways to skin a cat. Which one to use depends on what you intend to do with the pelt.