use file_put_contents instead of the File-class