The first error is to use append mode. You want to write to the file and not add something to the end of the file.
The other thing is that you need to find where the first line ends and start writing soon after. There are several ways to do this. One of them is simpler is to rewrite the first line after reading it. I think you tried to do but actually threw the contents of the first line on top of the file handle, that is, you lost the connection to the file.
In fact there is another problem. The second line may be larger or smaller than the original content, so it would be better to write back everything later.
$fn = fopen('teste.txt', 'w'); //note que isto destrói o conteúdo do arquivo
$fc = file($fn);
$fc[1] = '-alteração na segunda linha';
file_put_contents($fn, $fc);
fclose($fn);
I kept the names of the variables so as not to confuse you but I do not know if they are not exactly the ones that confused you. Giving meaningful names to the variables helps a lot to understand the code.
Finally, do not attempt to access the file concurrently since there is no locking control in this algorithm.