title: Can't write string into .txt file
body: <p>I'm writing a udp protocol code, one of the functions in the server side is to write the received string into a output .txt file.</p>
  
  <p>Here is part of my code about this problem</p>
  
  <pre><code>for (;;) 
  {
  
    fpout = fopen("out.txt","w");
    if(fpout == NULL){
      printf("Error!");
      exit(1);
    }
  
    int receive = 1;     
    while(receive)
    {
      bytes_recd = recvfrom(sock_server, &amp;pkt, STRING_SIZE, 0, (struct sockaddr *) &amp;client_addr, &amp;client_addr_len);
      if(pkt.length == 0)
        receive = 0;
      printf("Server received Sentence is: %s\n     with length of %d\n", pkt.databytes, pkt.length);
  
      printf("Server received %d packet\n",pkt.seqnum);
      strcpy(sentence, pkt.databytes);
      fprintf(fpout, "%s", sentence);
    }
    fclose(fpout);
  }
  </code></pre>
  
  <p>pkt is the struct I transmitted, pkt.databytes is the string part I want to write into the .txt file. 
  But right now, nothing writes into the out.txt file. </p>