modified file opening/closing in monitor-{file|device}