Fixed infinite loop etc

added ".encode("utf-8")" to prevent an infinite loop and to filter out keywords properly