Problem in reading files with copied content

I am constantly getting this problem as whenever i copy some paragraph or content to my .txt file and after using .readlines() command, i try to get print of the result i got a empty matrix. here i also use the .close() in the end also.
And when i write 1 or 2 lines by myself and save it with other name and run it on same syntax just by changing the file name i got result.
please give a good reason for my problem. As i also shared my screenshot in my previous doubt as the file was also not empty but i got no genuine support regarding this.
please let me knew about the problem.

Hi @Sunny, can you please share the link of your notebook that you’re working on? Will try to help you out with the issue.

hello sir here is the screenshot for the self made .txt file and its work.

here is screenshot of the copied content.

i have uploaded such screenshot in my previous doubt topic also but i got no response, hoping that you might help me this tym as my progress is struck at this point for a long tym.

Hi,

will you please change your file handler name from file to something else like myfile and check your code again
example

myfile = open("poem.txt","r")
val = myfile.read()
print(val)
myfile.close()

I am getting this error again and again.

As per error mentioned in screen shot, you are facing unicode related problem, it is not related to python.

I suggest you delete your current file and create new to remove any text encoding problem. Also share your result.

thanks for your reply but this didn’t worked.

please share your text file.

sorry sir, no option to share a text file.

Ishvinder sir, could you help me with this topic

I don’t know exactly what is the issue with your runtime… it’s running fine for me
Can you share your version of poem.txt file?

Maybe copying the content and creating your own txt file can do so, try downloading the original poem.txt file from download materials, right click on download button, and then click “Save link as” and save it as poem.txt

sir, i found no option in this reply option to share a .txt file.

it worked. but i am still confused why my copied content into the text document didn’t worked. It is a bigger doubt with me.

It’s because it was using some other encoding when you were doing it manually. This is exactly what the error says in your screenshot.