Borrowed script for watching for changes in console mode.