SD card

Hello everyone, I have to read the content of a variable from a .txt and an .htm file. I also have to write other thing in this txt/htm file but th funtion file.print(); doesn't work. The listing is:

#include <SPI.h> //LIBRERIA PER COMUNICAZIONE
#include <SD.h> //LIBRERIA PER CONTROLLO SD

File file,myFile; //DICHIARO FILE DI NOME "file"
int a=1;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);

Serial.print("Initializing SD card...");

//INIZIALIZZAZIONE SCHEDA SD

if (!SD.begin(4)) { //) CONTROLLA SE LA SD E' SUL PIN 4
Serial.println("initialization failed!"); //) E' NECESSARIO CHE LA SD SIA SUL PIN 4
return; //) PER LA ETHERNET SHIELD
}
Serial.println("initialization done.");

myFile = SD.open("test.txt");
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();}

file = SD.open("prova.htm"); // APRE IL FILE "pagina.txt" (NOME REALE DEL FILE)
if (file) {
//Serial.println("test.txt:");

// read from the file until there's nothing else in it:
while (file.available()) { //CONTROLLA SE CI SONO ALTRI BYTE DEL FILE DA LEGGERE
Serial.write(file.read()); //INVIA I DATI IN FORMATO CARATTERE

}
file.print(a);
file.close(); //CHIUDE IL FILE
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}

void loop() {
// nothing happens after setup
}

Please answear me as soon as possible. If you're italian answear me in italian. Thank you

What doesn't work?

ieee488:
What doesn't work?

His code, obviously. He's Italian. That's all you need to know.

Isn't it?

Well, no, OP, it isn't. The code does something. You expect it to do something. All we know at this point is that the two somethings are not the same thing.

the problem is that I have to read the content of a variable in an hmt file

There are no variables in htm (or hmt) files. There may be VALUES that you want to store in a variable.

That does NOT explain what the program ACTUALLY does.

And as far as where you are, and where Arduinos are made, that matters not at all. What matters is you (in)ability to ask a technical question in a technical forum, and understand the answers.

Marco, Thanks for your partecipation. We not need user like You.
Ciao Uwe