Thanks! That works, but now I'm having issues getting it to work if file.txt is on the desktop. This is what my path looks like: C:\\Users\<MY NAME HERE>\Desktop\file.txt
EDIT:
It seems like changing all the backward slashes to double worked. C:\\Users\\<MY NAME HERE>\\Desktop\\file.txt
The backwards slash in a string was probably confusing it.
.
Yes, that would do it. A backslash inside a string is interpreted as an escape for the subsequent character. If you want a backslash to be part of the actual string, you need to escape the backslash itself, i.e. a double backslash.