Answering how search engine work from classroom question

I am not sure whether to post my approach to question asked in classroom here in this forum, but here I am posting for the first time, if it is not the place to post such answer please do let me know for next time.

My approach:

As given in a directory with bunch of files (similar to number of webpages in internet), our task is to search for word say “hello” and show the best possible result to the user.

Firstly, similar to crawling step in web, I will search for all files in directory for the presence of search word “hello” in our case. Secondly, similar to indexing step, I will index all files with number of occurrence of word “hello”. Like maintain a kind of mapping/dictionary from file to count frequency. Lastly, similar to ranking step, I will sort all the indexes in decreasing order (highest frequency at top) and return the top 10 index result to the user.

Pseudocode

result = {}
searchword = "hello"
allfiles = list of files from directory
for currentfile in allfiles:
    count = 0
    allLines = list of all lines in currentfile
    for currentline in allLines:
        for currentWord in currentline:
            if currentWord == searchword:
                count++
    
    result[currentfile] = count

Now sort the result by values in the dictionary result. (we can use the ordered dictionary). Finally we can return the top 10 result or alike to the user.

Time complexity would be O(nm), provided n number of files in given directory, m number of lines in each file. Assuming total word in each line is constant say k words, then we can say O(kmn) time.

Please give some feedback on my approarch. (@ArnavGupta sir)