Only one value printed on the serial monitor

Hello everyone, I’m quite new to Arduino, and right now I’m trying to use an ultrasonic sensor, namely an HY-SRF5. Here’s the documentation for it.

And it worked as advertised.
After playing around a little bit with it, I decided to try and write my own code instead of the provided one, which should do the same. The code is as below (I know it’s not precisely good code, but it almost worked):

unsigned long int time1; //Time stamps
unsigned long int time2; 
int timedifference; 
int outPin = 12; 
int inPin = 13; 
int constant = 58; // change to 148 te get measurement in inches

void setup() {
  // put your setup code here, to run once:
  pinMode(outPin, OUTPUT); 
  pinMode(inPin, INPUT); 

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(outPin, HIGH); // Begin pulse 
  digitalWrite(outPin, LOW); // End pulse
  while(true) // Basically, wait for a signal
    if (digitalRead(inPin) == LOW) {continue;} // Just go back if it's not here yet
      time1 = micros(); 
      while(digitalRead(inPin) == HIGH) // Stay here as long as needed
      time2 = micros(); // This happens after echo is finished
      timedifference = time2 - time1;

      Serial.println(timedifference/constant); // Get distance in cms 
  delay(1000); // Wait a bit

This code is OK for measuring distances, but for some curious reason, it messes up the serial monitor, which only displays one value. If I close and open it again, it shows a different one. I suppose the one that’s shown is always the last one it received.

Has anyone encountered this before? Is this some kind of weird bug or did I really mess something up?

Thank you in advance for your help.

You have an endless loop inside "Loop"! So you never trigger the ultrasonic again.

Oh my God, how did that elude me... Thank you very much!