I want to create a read/write file.Whenever I open it(even if it already exists) I want it to truncate itself.

The only way I found how to do it was via a streambuf from the book 'Thinking in C++':

Code:
#include "../require.h"
#include <iostream>
#include <fstream>

using namespace std;

int main() {
    ifstream in("Iofile.cpp");
    assure(in, "Iofile.cpp");
    ofstream out("Iofile.out");
    assure(out, "Iofile.out");
    out << in.rdbuf(); // Copy file
    in.close();
    out.close();
    
    // Open for reading and writing:
    ifstream in2("Iofile.out", ios::in | ios::out);
    assure(in2, "Iofile.out");
    ostream out2(in2.rdbuf());
    cout << in2.rdbuf(); // Print whole file
    out2 << "Where does this end up?";
    out2.seekp(0, ios::beg);
    out2 << "And what about this?";
    in2.seekg(0, ios::beg);
    cout << in2.rdbuf();
} ///:~
I don't want to use a streambuf so I tried the following:
Code:
#include <fstream>
#include <string>

using namespace std;

int main() {

    fstream out("Texttest.txt",ios::out|ios::in|ios::trunc);
    ifstream in("Text.txt");
    out<<in.rdbuf();
    out.seekp(0,ios::beg);
    string s;
    out>>s;
    cout<<s;
    cin.get();
}
When I run it prints on the screen ZKM7461(see below the file Text.txt).This happen for every execution,as it should be.

But when i run it with the file 'test21.txt' replacing the file 'Text.txt'
it prints 'Λ212324' whenever it wants.Some times it prints it,some others it doesn't print anything.
What is happaning?
Are there any other suggestions in how I could have a read/write file the way I want it to be?

Text.txt:

ZKM7461 FORD Ka
YRM3245 TOYOTA Corolla
ET9672 PEUGEOT 204
ZZO7563 PEUGEOT 206

test21.txt:

Λ212324 ΠΕΤΡΟΣ ΑΝΑΓΝΟΥ Μυρσίνης 3 15765 1
Α124456 ΣΠΥΡΟΣ ΠΕΤΡΟΥ Δοιράνης 8 34489 0
Β456765 ΗΛΙΑΣ ΑΝΑΣΤΑΣΙΟΥ Ελπίδος 14 15568 1
Ζ455467 ΑΝΔΡΕΑΣ ΚΑΛΟΣ Αθηνάς 35 16472 1
Χ789342 ΙΩΑΝΝΗΣ ΤΣΑΝΑΚΑΣ Κορυτσάς 68 32467 0
Λ343434 ΑΝΤΩΝΗΣ ΣΤΑΜΟΥ Περικλέους 2 32256 1
Τ565678 ΚΩΣΤΑΣ ΠΑΠΠΑΣ Παλαμά 87 44566 1