So first of all, good job thinking in this way. You clearly have a good grasp on what is going on with your system and are cognizant of where your data is.
So first off, the text file. This is something you may want to encrypt with a password. You can make encrypted containers with an open source tool called Veracrypt. Just stick with default options when encrypting and choose a strong password.
For your browser history and such, what you’re worrying about there is called an info stealer. Info stealers generally do what it says on the tin, steal info. Like browser history, but also your login cookies, which enable an attacker to paste them into their browser and be logged in to all your accounts. Info stealers sometimes come as a part of a document, or as a script that it tries to trick you into running. One thing you can do is enable the option in Finder to display all file type extensions so that you can see the true nature of the files you’re about to click.
To protect against this, simply do not install sketchy browser extensions and do not disable any of the security MacOS comes with by default. It may be slightly inconvenient, but if you stick with MacOS’s default security settings you don’t need to worry much about this beyond applying common sense to what you install.