Serial problem

I have tried another program that apply the principles but with a shorter void read. It works.

Does anybody know why?

void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(5000); // wait for a second
read();
digitalWrite(13, LOW); // set the LED off
delay(1000);
}

void read()
{
if (Serial.available())
{
char val = Serial.read();
Serial.print(val);
}
}