Refactored monitor() to use putchar.