✅ New Features Included
Live Record Count: Label shows how many studies have been written.
Pause/Resume Button: Temporarily halt and resume querying without killing the session.
Stop Button: Gracefully terminates the process early.
Real-Time File Writing: Ensures each writer.writerow() call flushes immediately.
📝 Notes
f.flush() is automatic now with buffering=1 (line-buffered mode).
self.pause_event.wait() halts progress until "Resume" is pressed.
self.stop_event.is_set() stops the loop immediately.