Creating a file from a block

Permalink
Hello,

I have created a block. In the blocks 'view.php' i create a new file and write some text to it. I then want to link to the file below it.

The file is not being created=, i have checked all of the directories...
Is there something I need to add to get it to create the file..?
(My Code):

<?php
$my_file = 'tester.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file); //implicitly creates file
$my_file = 'tester.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
$data = 'tester
';
fwrite($handle, $data);
?>
<a href="tester.txt">view file</a>


Any advice would be much appreciated.

Thanks