Why do I need to finish by using the fclose($handle)
function after writing to a file using php? Doesn\'t the program automatically do this when it ends?
Yes. But, it's good practice to do it yourself. Also, you'll leave the file open during the entire exection of the remainder of the script, which you should avoid. So unless your script finishes execution directly after you're finished writing, you're basically leaving the file open longer than you need to.