in reply to No such file or directory

It looks like you are trying to open a file named New Text Document.txt which you expect to be in the current directory from which you ran your code. Apparently, there is no file with that exact name. Check the spelling, check for spaces, check if you are really in the correct directory.

See also Writeup Formatting Tips for how to use the code tags.