You are using
'a' mode. According to the PHP documentation:
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it. In this mode, fseek() has no effect, writes are always appended.
So, you need to use
'w' mode. Like this:
$fisier = fopen("bune.txt", "w");