change fopen to wr+