Cannot open a file from SD when using multiple loops [SOLVED]

I am not familiar with the Keypad library. What does the function waitForKey() do?

Also, maybe you can explain how the working program is used. I don't have a keypad so I can't try it out.

...R