My first thought was that bad_goose was being rude, but attempting to figure out what you are trying to do, I have to agree.
First, you set $array1[$y] to what's in $array1[$y+1], then the next line overwrites it. So the first assignment is gone.
Second, you are opening the file inside the loop, over and over again. That's not good.
Please explain what you are trying to do (append to the file, rewrite the file, etc.). And what is supposed to be in $array1?