I’m sorry you lost your writing, especially text you had already saved. On Windows 10, checking for an earlier backup of the file is a good place to start.
Here are some suggestions you can try:
First, make a separate copy of the file as it is now, and avoid saving over the original.
Open File Explorer, find the folder containing your text file, right-click the folder, and select Restore previous versions. If a version from before the loss appears, open it and check your file. Use Restore to… to recover it to a different location without replacing your current copy. This requires a backup that already existed before the text disappeared.
If your file was saved in OneDrive, right-click it and select Version history. Choose an earlier version, select the three dots beside it, then Restore. This supports text files too.
If neither option has an earlier copy, recovery isn’t guaranteed. Turning on backups now can protect future writing, but won’t recreate the missing text.