title: Cannot append text to file with sftp_open()
body: <p>I'm trying to learn libssh. I want to append text that user typed to a file, but when I use O_APPEND access type in <code>sftp_open()</code> it doesn't do anything. If I will use O_WRONLY access type then it will write something in file but it doesn't look correct(some characters are hidden). The only message I have is when I'm checking if the number of bytes written equals size of variable that contains user's input. It writes that the bytes written doesn't equal size of the variable but <code>strerror(errno)</code> returns &quot;Success&quot;. If I'm using O_WRONLY then I am not getting any messages.
  So, any ideas what the problem is? Maybe I have problems with permissions?</p>
  <pre><code>#include &lt;libssh/libssh.h&gt;
  #include &lt;libssh/sftp.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;string.h&gt;
  int sftp_write_sync(ssh_session session, sftp_session my_sftp_session, char login[31], char password[31])
  {
      sftp_file fd;
      int nwritten;
      // Making format for writing to recognize every field when read, you can omit it
      char new_login[35] = &quot;&quot;;
      strcat(new_login, &quot;\n:&quot;);
      strcat(new_login, login);
      strcat(new_login, &quot;:&quot;);
      fd = sftp_open(my_sftp_session, &quot;/home/user/Users.txt&quot;, O_APPEND, 0);
      nwritten = sftp_write(fd, new_login, sizeof(new_login));
      sftp_close(fd);
      return SSH_OK;
  }
  </code></pre>