Question: My problem here is that i don't know how to properly write a file using `fwrite`. I parse xml using simplexml and then, while `echo` works fine, i can't write the same result in a file. In this example below, i echo 5 items from an xml feed, but when i write it to a file, it writes the 5th item only. Can anyone tell what's the problem?

```
$file = simplexml_load_file($url); {
$c = 0;
foreach($file->channel->item as $post) {
if($c == 5){
break;
}

$headline = (string) $post->title;

echo $headline;

$fp=fopen('myfile.htm', "w+");  
fwrite($fp, $headline."<br />");
fclose($fp);
        $c++;
        }
}

```

**EDIT :** Second attempt . I used a `while` loop, instead of `if`, but i only managed to write **5** times the **5th** item. I need `w+` (and not `a+`) to overwrite file every time it is updated and not add content each time:

```
$file = simplexml_load_file($url); {

foreach($file->channel->item as $post) {

$fp=fopen('myfile.htm', "w+");
$c = 1;
while ($c <= 5){
    $headline = (string) $post->title;
    fwrite($fp, "$headline<br />");
    $c++;
}
fclose($fp);
}
include 'myfile.htm';
}

```

Answer: 
If you use **Visual Studio Tools for Office 2010 (VSTO 4.0)** then it will compatible for `Office 2007 ,Office 2010 and with Office 2013`.If you use earlier version other than the above then you can use that only for particular office versions only.As a example `VSTO 3.0` only supports `office 2003 and 2007` as shown below table.

For more information check this out [**Visual Studio Tools for Office**](http://en.wikipedia.org/wiki/VSTO) and [**Visual Studio 2010 Tools for Office Runtime**](https://www.microsoft.com/en-za/download/details.aspx?id=44074)

compatibility Shows like below:

![enter image description here](https://i.stack.imgur.com/Z8qec.png)

I hope this will help to you.
you can take a look at [Netoffice](http://netoffice.codeplex.com), a wrapper for MS Office that enables you to create Addins for all supported versions of MS Office. You don't need VSTO and you can check within your own code which version of Office your AddIn is running in.