Fixed encoding issue for file reading. Added doctests.