I've found this script ([How to add timestamp to STDERR redirection](https://stackoverflow.com/questions/1507674/how-to-add-timestamp-to-stderr-redirection?lq=1)) to redirect stdout/stderr of a script/program and add a time stamp:

```
#!/bin/bash
while read line ; do
    echo "$(date): ${line}"
done

```

when using this script (predate.sh) like

```
./MyApp | predate.sh > out.log

```

it works great, but when MyApp crashes or gets killed, the predate.sh script continuously runs and does not terminate. Does anyone know how to solve that?