It is slightly different. It writes p.e. a temporary file to a directory that is maybe not accessible for the user???
The above function works without any temp file. Much nicer.