Thanks so much for the help but it is still not working.
When defining the index to put the new array element all other elements are knocked off the end of the array:
function insert_line($addLine, $position) {
$buffer = file("lines.inc");
$buffer[$position] = $addLine."\n";
for($i=0; $i<=$bufflines; $i++) {
echo($buffer[$i]); //should be fwrite just testing in what order the array is populated
}
}
insert_line("line2","1"); //trying to insert line2 between line1 and line3 in lines.inc