You posted your question a while ago, and I see it is still not answered.
I investigated it a bit, and I found the following issues:
The #!/bin/bash and #!/bin/sh commands are working differently, and the automated test uses the bash.
Furthermore, during the test, the parameters are given as program arguments and not as user input. Thus, you might fail with the read command. Somehow, I could only evaluate the given program argument ($1) once; therefore, I always store it in a global variable before performing multiple evaluations.
A third issue is that you declare the list by itself, but in bash, you should use the following declaration: declare -a words=("string1" "string2" "string3")
I hope you will find it useful to debug your code.