Move the monitoring of the file modification to the beginning of the fun.

Signed-off-by: Martin Raspaud <martin.raspaud@smhi.se>