Without the stack trace, it's hard to tell what is wrong, but my first guess would be that you saved at least one file as utf8 with BOM. Or some other encoding not understood by python.
Explaining what that means is a bit technical. Text file are really a list of rather small number. Each letter is given a code composed of one or more number. If the text file and python use different encoding, you can get sequence of number which corresponds to no character. That one way to get an invalid character.
Another way is the BOM symbol. That's two number placed at the start of a file encoded as utf8. But if the app reading the file don't expect the BOM, it will try to turn it into a letter and get an invalid character.
If you have an invalid character on the first line, first letter, there is a good chance the problem is BOM.