I have a large number of Terminal windows, that I keep open so I can have a record of what I did, and what the responses were.  The windows all have titles indicating the problem space they're for, but sometimes something gets done in the "wrong" window.

How can a do a single search across all the windows? Is there an app out there that will read the saved Terminal contents, and write them as text?  Even better, is there source code for doing that?

I have this AppleScript:

    tell application "Terminal"
    	set windowName to ""
    	set windowContents to ""
    	
    	repeat with theID from 1 to (count windows)
    		set windowName to the name of window theID
    		log windownName
    		set windowContents to the contents of every tab of window theID
    		log windowContents
    	end repeat
    end tell

For which I get told:

error "The variable windownName is not defined." number -2753 from "windownName"

Final end product will be writing "The file is: <file name>\n<File contents>", but AppleScript seems intent on keeping me from doing so