Printing the servo position on LCD

I am trying to print the servo position on the 16X2 standard LCD.
Here is the code i am using.The problem is that when the servo moves from 0 to 180,the values are printed properly but when the servo moves from 180 to 0,the value prints properly till 100 and below 100 the value goes to 950 and decreases.Heres the code.
The servo sweep is enabled by pressing a pushbutton.

 #include <Servo.h>
 #include <LiquidCrystal.h>

int buttonPin = 8;
int pos = 0;

Servo myservo;
int buttonState = 0;  

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
pinMode(buttonPin, INPUT);    
lcd.begin(16, 2);
lcd.print("Press a Button");

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH){
 for (pos = 0; pos < 180;pos +=5)                               
    lcd.setCursor(9, 0);
 for(pos = 180; pos >=1; pos-=5)    
    lcd.setCursor(9, 0);    

This is the first time i am using LCD and pushbutton so i dont know whether the code is written in proper manner.

When you write a 1, 2 or 3 digit number, the cursor moves from position 9 onwards for the required digits

When you write a "longer" number over a "shorter" number all is well.

Clue: What happens when you write a "shorter" number over a longer one ?

Replace your lcd.print(pos); by the following code combination:

if (pos<100) lcd.write('0');
if (pos<10) lcd.write('0');

This will make sure you always output 3 characters so the previous out, as pointed out by Msquare, is overwritten by new outputs and no garbage is left on the display. You can also replace the ‘0’ by ’ ', a space, if you want space padding instead of zero padding.