It's possible your file name is really "test.txt.txt". If you're using windows, open the folder options and uncheck the box that says "hide extensions of known file types".
If you run your program from an IDE the working directory is often not the same as the directory where the executable file is located. Try putting the file in the project directory.