title: file operation write is not happening in new line
body: <p>Hi following code sample seems to have some problem or either it has to do something with OS internals.</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
      #include &lt;unistd.h&gt;
      #include &lt;string.h&gt;
      #include &lt;sys/types.h&gt;
      #include &lt;sys/stat.h&gt;
      #include &lt;fcntl.h&gt;
  
      static void usage();
      #define MONC_AM_CONF "/tmp/monc.conf"
  
  int main(int argc, char **argv)
  {
          int ch;
          char list[200];
          int len;
          int fd;
  
          memset(list,0,200);
          if (argc &lt; 11) {
                  usage();
                  exit(1);
          }
  
          while ((ch = getopt(argc, argv, "N:S:P:H:R:")) != -1) {
                  switch (ch) {
                          case 'N':
                                  len = strlen(optarg) + 2;
                                  sprintf(list,"%s::",optarg);
                                  break;
                          case 'S':
                                  sprintf(list+len,"%s::",optarg);
                                  len = len + strlen(optarg) + 2;
                                  break;
                          case 'P':
                                  sprintf(list+len,"%s::",optarg);
                                  len = len + strlen(optarg) + 2;
                                  break;
                          case 'H':
                                  sprintf(list+len,"%s::",optarg);
                                  len = len + strlen(optarg) + 2;
                                  break;
                          case 'R':
                                  sprintf(list+len,"%s ",optarg);
                                  len = len + strlen(optarg);
                                  break;
                          default:
                                  printf ("You specified a parameter I don't "
                                                  "know about.\n");
                                  break;
                  }
          }
          argc -= optind;
          argv += optind;
  
          printf("Total length of string is %d\n",len);
          printf("The string is %s\n",list);
  
          fd = open(MONC_AM_CONF, O_WRONLY|O_CREAT|O_APPEND, 0644);
          lseek(fd, 0,SEEK_END);
          write(fd,list,len);
          close(fd);
  
          return 0;
  }
  
  static void usage()
  {
  printf("Please provide the command in correct format\n");
  printf("monc_am_config -N &lt;Comp_Name&gt; -S &lt;Start Script Path&gt; -P &lt;Stop Script Path&gt; -H &lt;HealthCheck Script Path&gt; -R &lt;Recovery Policy&gt;\n");
  
  return ;
  }
  </code></pre>
  
  <p>When I am issuing commands I am getting the output file each time different. 
  I am expecting execution of this program each time should write the information in the new line but it is writing into the same line in the file.</p>
  
  <p>Plz help.</p>