When you open a file for writing with option 'w' it completely wipes all data from that file.
This action is also referred to as "truncating" a file.
Truncate literally means to shorten.
To erase all the data from a file we need to open the file for normal writing.
All existing data within the file will be lost.
Truncating is most often used on files that contain data that will only be used for a short time.
These type of files are most often referred to as temporary files.
For more detail please see Php Manual at http://www.php.net