watch_directory(): fix local variable reuse