Hint: what if your name input is not matched by the first line of the file? If they don't match keep going, reading in lines until it does. You need another loop.
Using "out" as the name of your input file might be confusing to someone (or you!)trying to read your program later.
Also, what happens if the file is not found or went bad?