Bug 1: Missing an end to close the for loop.
Bug 2: grades only has 5 elements, so the loop tries to access something that does not exist, i.e. grades(6).