print #handle, "!modified? answer$" ;

This command returns a string (either "true" or "false") that indicates whether any data in the text window has been modified.  The variable answer$ holds this returned string.  This is useful for checking to see whether to save the contents of the window before closing it.