$path = 'data.txt';
$id = $_GET['id'];
$fp = (fopen($path, "\r\n"));
$post = 'a file has been downloaded';
fwrite($fp, $post);
fclose($fp);
Use an absolute path for your datafile. For example, is data.txt in the same folder as your php script? For php file functions, remember that any path argument is NOT relative to the virtual root. You can use the variable $DOCUMENT_ROOT however to inject the absolute path (filesystem path) to your Web server virtual root.
Example: (IF your file to open is in your virtual root!)
$path = $DOCUMENT_ROOT . 'data.txt';
Where you have used '\r\n', this is for the file open mode for fopen function. I have no clue what you are trying to set it as (looks like you have it confused as nifty place to insert a carriage return.) This should be 'a' only. This tells the function to open the file for writing only and place the cursor at the end. If you use:
$post = 'a file has been downloaded\n';
with a nice newline after it, the cursor should always be placed on a brandnew line (you can try without the newline, the 'a' option may just do it for you. Try 'em both.)