title: Write string to a .txt file, FileOutputStream is not working as expected
body: <p>I have an app and I want to create a text file and write something in it. I use explicit intent to select folder and create file, where mimeType=text/plain </p>
  
  <pre><code> private void createFile(String mimeType, String fileName) {
      Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
      intent.addCategory(Intent.CATEGORY_OPENABLE);
      intent.setType(mimeType);
      intent.putExtra(Intent.EXTRA_TITLE, fileName);
      startActivityForResult(intent, WRITE_REQUEST_CODE);
  }
  </code></pre>
  
  <p>after creating the file I use onActivityResult to write to it </p>
  
  <pre><code>if (requestCode == WRITE_REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK) {
          Uri uri = resultData.getData();
          String path = uri.getPath();
          File file = new File(path);
          String filename = file.getName();
          try {
              verifyStoragePermissions(this); //method to access storage
              FileOutputStream outputStream = openFileOutput(filename,MODE_PRIVATE);
              outputStream.write("Message to write".getBytes());
              outputStream.flush();
              outputStream.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>I also have permitions in my manifest</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>I don't get an error but there is nothing written in my file. Can anyone help?</p>