Help: How can I keep writing in a file?

 

I wanted to keep error logs in a file, but the programme overwrote the previous logs and there was always one line. In the documentation, the example says that using SEEK_END can move to the next line and keep writing, but it didn't work for me. Also, sometimes when I opened the file and it showed "0: no error". I thought the IF statement would keep "0: no error" away from the log.


Is there any wrong with my code? Thanks for your help.


if(GetLastError() != 0)

{

int EA_Error_Handle = FileOpen(EA_Error_File,FILE_WRITE,";");

FileSeek(EA_Error_Handle,0,SEEK_END);
FileWrite(EA_Error_Handle,GetLastError() + ": " + ErrorDescription(GetLastError()));
FileClose(EA_Error_Handle);

}

 
Open the file for read/write.
 
phy:
Open the file for read/write.

Thanks for you rely, but I still didn't understand. Could you explain in detail to me, please?

 

Read carefully:

https://docs.mql4.com/files/FileOpen

Also, you complain about GetLastError().

Read carefully:

https://docs.mql4.com/check/GetLastError

 
Thanks a lot. Both of them are working properly now.
Reason: