Something’s gone wrong in the encoding and decoding. When you tried to read ten characters, did you open the file with encoding=“utf-8” same as in the example here?
Yep! That would be it Getting file encodings correct can be hard, but following a discipline of “always encode and decode UTF-8” will usually make things work fairly well.
What version of Python are you using? Some of these things have become easier with newer Python versions.
In the future, please make sure to show a proper minimal, reproducible example when asking questions about programming anywhere online. That will make it easier to understand the problem, and ensure that there hasn’t been some unrelated problem (e.g. forgetting to save changes to a file before running it). The code that you show in the first question can’t possibly be right, because a path like “C:\Users\tech_worker\segismundo.txt” will not work - the quotes are wrong, and the backslashes are not escaped. Although I think both of these happen simply because you have not properly formatted the code, as described in the pinned thread.
As you found, the problem was with specifying the encoding for the open call, but your original code shows that being done properly - so that can’t be what actually went wrong. It’s important to be able to reproduce problems in order to talk about them properly.
Note that on many (all?) *nix systems, (and some recent Windows as well), utf-8 is the default encoding, so a LOT of people will omit it and it will work fine, and then someone else gets bitten
This is because Python uses the system default encoding, (locale.getpreferredencoding(False)), and Windows systems often had other encodings – IIUC, Windows is moving teh utf-8, but I"msure this will be an issue for a long time.
Python itself is moving to make utf-8 the default, but I have no idea when that might happen – it could break a fair bit of code in Windows machines