php数组不按预期写入文件

basically im reading everything from my file, pushing it to array, and then rewriting the file with arrays so no data is lost

This is my text file after i write array. Pirmadienis,Antradienis,etc are stored on different arrays. When i write "Pirmadienis" array it starts in second line and pushed the other one to side.

Pirmadienis
"array fwrite here" Antradienis
Treciadienis
Ketvirtadienis
Penktadienis

This is php i use. $pirm is an array for "Pirmadienis". I use 4 more foreach loops so each array is writen into file. Any ideas why its creating a new line?

$file = fopen($failas,"w+");
foreach($pirm as $key => $value) {
fwrite($file,$value); 
}