How do I programmatically create a file and write it in the private:// folder?
If anyone need it, I make it work: 

use Drupal\Core\File\FileSystemInterface;

...

  /**
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $fileSystem;


  public function __construct(FileSystemInterface $fileSystem) {
    $this-&gt;fileSystem = $fileSystem;
  }

  public function testCreation() {
    $request = 'test content';
    $path = 'private://gmt/';
    if ($this-&gt;fileSystem-&gt;prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY)) {
      /** @var \Drupal\file\FileInterface $file */
      $file = file_save_data(
        $request,
        $path . 'requests.txt'
      );
    }
  }