在编辑PHP时显示文件的现有内容

I open a .ini, then write some add some values to its parameters and then i saved it back.

My writing the content works perfectly fine, but when i open the file the previous content of that file is cleared.[Maybe due to my write mode].

What change should i do in my code to let user see what the previous content was when he edits a file.

file_get_contents($path.$filename); 

    /*Get All The datas from that file*/

    $this->data['params'] = $this->parameter_m->get();

    /*Getting the parameters to display on view*/

    $this->data['parameters']  = parse_ini_file($path.$filename,true);

    while (current($this->data['parameters']) ) 
    {
        $param_set = current($this->data['parameters']);
        $param_type = key($this->data['parameters']);

            foreach ($param_set as $key =>$value) 
            {

                $this->data['parameters'][$param_type][$key] = $this->input->post($key);

            } 

        next($this->data['parameters']);
    }

    $this->load->helper('file');

    $this->load->library('ini');

    $file = $path.$filename;

    $ini = new INI($file);

    $ini->read($file);



    $ini->write($file, $this->data['parameters']);

My Write Function

function write($file = NULL, $data_file = array(), $sections = TRUE) {
    $this->data_file = (!empty($data_file)) ? $data_file : $this->data_file;
    $this->file = ($file) ? $file : $this->file;
    $this->sections = $sections;
    $content = NULL;

    if ($this->sections) {
        foreach ($this->data_file as $section => $data_file) {
            $content .= '[' . $section . ']' . PHP_EOL;
            foreach ($data_file as $key => $val) {
                if (is_array($val)) {
                    foreach ($val as $v) {
                        $content .= $key . '[] = ' . (is_numeric($v) ? $v : $v ) . PHP_EOL;
                    }
                } elseif (empty($val)) {
                    $content .= $key . ' = ' . PHP_EOL;
                } else {
                    $content .= $key . ' = ' . (is_numeric($val) ? $val : $val ) . PHP_EOL;
                }
            }
            $content .= PHP_EOL;
        }
    } else {
        foreach ($this->data_file as $key => $val) {
            if (is_array($val)) {
                foreach ($val as $v) {
                    $content .= $key . '[] = ' . (is_numeric($v) ? $v : '"' . $v . '"') . PHP_EOL;
                }
            } elseif (empty($val)) {
                $content .= $key . ' = ' . PHP_EOL;
            } else {
                $content .= $key . ' = ' . (is_numeric($val) ? $val : '"' . $val . '"') . PHP_EOL;
            }
        }
    }

    return (($handle = fopen($this->file, 'w+')) && fwrite($handle, trim($content)) && fclose($handle)) ? TRUE : FALSE;
}