Those are 5 returns and your code switches from one code to another, it doesn't stop at the second 'line' since you're setting that to false again.
And if you just want to add multiple lines with multiple different content you don't need any loop... just use fopen() and fprint() or just write_file() and it will write the data on a new line.