Stream reading characters that aren't in the file
<p>When I read in a file I am getting three characters being read first which aren't in the file.</p>

<p>They are: "ï»¿"</p>

<p>The file contains:</p>

<pre><code>&lt;root&gt;
  &lt;tag&gt;
    &lt;anothertag&gt;Text&lt;/anothertag&gt;
  &lt;/tag&gt;
  &lt;tag&gt;
    &lt;anothertag&gt;Text&lt;/anothertag&gt;
  &lt;/tag&gt;
&lt;/root&gt;
</code></pre>

<p>My code:</p>

<pre><code>//scanner.h
enum TOKEN_TYPE {
    OPEN, CLOSE, TEXT
};

struct Token {
    int type;
    std::string value;
};

class Scanner {
public:
    Scanner(std::string path);

    void scan(std::string path);

private:
    std::vector&lt;Token&gt; tokens;

    Token readToken(std::ifstream&amp; in);
};

std::string read_to(std::istream&amp; in, char delim);

//scanner.cpp
Scanner::Scanner(std::string path) {
    scan(path);
}

void Scanner::scan(std::string path) {
    std::ifstream in(path, std::ios_base::beg);

    if(!in.is_open()) {
        return;
    }

    if(!tokens.empty()) {
        tokens.erase(tokens.begin(), tokens.end());
    }

    std::ofstream out("output.txt");
    while(!in.eof()) {
        tokens.push_back(readToken(in));

        if(tokens.back().value.empty()) {
            tokens.pop_back();
            continue;
        }

        out &lt;&lt; tokens.size() &lt;&lt; "\t" &lt;&lt; tokens.back().value &lt;&lt; "\t" &lt;&lt; tokens.back().value.length() &lt;&lt; std::endl;
    }

    in.close();

    out &lt;&lt; "\n";
    for(int i = 0; i &lt; tokens.size(); ++i) {
        if(tokens[i].type == TOKEN_TYPE::TEXT) {
            out &lt;&lt; tokens[i].value &lt;&lt; std::endl;
        }
    }

    out.close();
}

Token Scanner::readToken(std::ifstream&amp; in) {
    Token token;

    char c = in.get();
    while(c == '\n' || c == '\t' || c == ' ') {
        c = in.get();
    }

    if(c == '&lt;') {
        c = in.get();

        if(c == '/') {
            token.type = TOKEN_TYPE::CLOSE;
            token.value = read_to(in, '&gt;');
        } else {
            in.unget();

            token.type = TOKEN_TYPE::OPEN;
            token.value = read_to(in, '&gt;');
        }
    } else {
        in.unget();

        token.type = TOKEN_TYPE::TEXT;
        token.value = read_to(in, '&lt;');

        in.unget();
    }

    return token;
}

inline std::string read_to(std::istream&amp; in, char delim) {
    std::stringstream str;

    char c;
    while((c = in.get()) != delim &amp;&amp; in.good()) {
        str &lt;&lt; c;
    }

    return str.str();
}


int main(int argc, char** argv) {
    Scanner scanner("test.xml");
    return 0;
}
</code></pre>

<p>Why is the stream reading these characters that aren't actually there?</p>
