Look at your code:
file= input("Enter file name(test.txt): ")
print('File cannot be opened:', file)
So if the code reaches the exception, it prints a message, and then recursively calls the function it's already executing which does exactly the same thing again. And again. And again ...
Why are you calling
in the exception handler code?