when i try to read return always zero

 

Hi guys  anyone  know  why  if  i try to read  a file  ib folder file  return me always  zero ? 

#property strict

input string TemplateName = "LINE";  // Nome template (senza .tpl)
input int ReadIntervalSeconds = 10;  // Intervallo di lettura file (in secondi)

string current_symbol = "";  // Simbolo attualmente aperto
datetime last_read_time = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   last_read_time = 0;
   current_symbol = "";
   Print("MarketWatch EA avviato. Leggerà il file ogni ", ReadIntervalSeconds, " secondi.");
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(TimeCurrent() - last_read_time < ReadIntervalSeconds)
      return;

   last_read_time = TimeCurrent();

   string filename = "MarketWatcH.txt";

   if(!FileIsExist(filename))
     {
      Print("File NON trovato: ", filename);
      return;
     }

   int file_handle = FileOpen(filename, FILE_READ|FILE_BIN);
   if(file_handle == INVALID_HANDLE)
     {
      Print("Errore apertura file ", filename);
      return;
     }

   ulong file_size = FileSize(filename);
   Print("Dimensione file: ", (int)file_size);

   Print("Contenuto file byte per byte:");
   for(uint i=0; i<file_size; i++)
     {
      // Legge 1 byte (char) come integer e converte a char
      int b = FileReadInteger(file_handle, 1);
      char c = (char)b;
      PrintFormat("Byte %d: '%c' (dec: %d)", i, c, b);
     }
   FileClose(file_handle);

   // Ora prova a leggere il simbolo normalmente (prima riga)
   file_handle = FileOpen(filename, FILE_READ|FILE_TXT);
   if(file_handle == INVALID_HANDLE)
     {
      Print("Errore riapertura file per lettura simbolo");
      return;
     }

   string symbol = "";
   while(!FileIsEnding(file_handle))
     {
      symbol = FileReadString(file_handle);
      symbol = StringTrimLeft(symbol);
      symbol = StringTrimRight(symbol);
      if(StringLen(symbol) > 0)
         break;
     }
   FileClose(file_handle);

   if(StringLen(symbol) == 0)
     {
      Print("File vuoto o simbolo non valido");
      return;
     }

   Print("Simbolo letto dal file: '", symbol, "'");

   if(symbol != current_symbol)
     {
      Print("Nuovo simbolo letto: '", symbol, "'. Cambio grafico.");

      if(!SymbolSelect(symbol, true))
        {
         Print("Simbolo non trovato o non selezionabile: ", symbol);
         return;
        }

      long chart_id = ChartOpen(symbol, PERIOD_CURRENT);
      if(chart_id <= 0)
        {
         Print("Errore apertura grafico per simbolo: ", symbol);
         return;
        }

      if(!ChartApplyTemplate(chart_id, TemplateName + ".tpl"))
         Print("Errore applicazione template: ", TemplateName);
      else
         Print("Template applicato con successo a ", symbol);

      current_symbol = symbol;
     }
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   // Nessuna azione richiesta
  }


 
Stefano Cerbioni:
   ulong file_size = FileSize(filename);
ulong file_size = FileSize(file_handle);