Read txt file and draw histogram

Hi
I try this

c1 = TCanvas("c1","c1",900,700)
h1 = ROOT.TH1F("h1", "", 10, 0, 10)
data = open('data.dat','r')
for x in data:
    print x
    x = Double()
    h1.Fill(x)
data.close()
h1.Draw()

and opened a white page Than I choose my txt file but cannot opened and said is not a root file
Secondly
I try this

string STRING;
	ifstream infile;
	infile.open ("names.txt");
        while(!infile.eof) // To get you all the lines.
        {
	        getline(infile,STRING); // Saves the line in STRING.
	        cout<<STRING; // Prints our STRING.
        }
	infile.close();
	system ("pause");

MY screen is:
but again I havent got a result:(
I cant open my txt file and I cant draw my histogram