Getting feedback from an fopen,fwrite,fclose sequence

I’m writing to a file and I want to know how I can get feedback from php to determine if the writing executed properly so I can display a message on the front end.