Remove unnecessary unlink().  Using fopen() with "w" mode recreates the file.