I am trying to make a hangman game in python but i get the attribute error in my title. this is my code

I have no idea what might be causing this attribute error in my code. I think it might have something to do with my code not having the correct naming or it might be how i defined in-File
import random
import string
WORDLIST_FILENAME = "words.txt"
def load_words(inFile=0):
"""
Returns a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
:param inFile:
"""
print("Loading word list from file...")
# inFile: file
open('words.txt', 'r')
# line: string
line = inFile.readline()
# wordlist: list of strings
words = line.split()
print(" ", len(words), "words loaded.")
return words
Error:
File "C:)Users\ ManyDog\ PycharmProjects\ hangman\main.py", line 49, in <module>
wordlist = load_words ()
File "C:)Users\ ManyDog\PycharmProjects\hangman\main.py", line 27, in Load_words
line = inFile. readline ()
AttributeError: 'int' object has no attribute 'readline'
>Solution :
You default inFile to an int but then try to use it as a file object. Internal to the function, you open a file but since you don’t use its returned file object, it is immediately closed.
Instead, read the opened file. In this example, I’ve used your hard coded file name as a default for the function.
def load_words(inFile="words.txt"):
"""
Returns a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
:param inFile:
"""
print("Loading word list from file...")
# inFile: file
with open(inFile) as fileObj:
# line: string
line = fileObj.readline()
words = line.split()
print(" ", len(words), "words loaded.")
return words