docs: public void write( Document document ) {
          assert document != null;
          ++count;
          ++totalCount;
          if (count > maxDocumentsPerFile) {
              // Close the stream (we'll open a new one later in the method) ...
              close();
              count = 1;
          }
          try {
              if (stream == null) {
                  // Open the stream to the next file ...
                  ++fileCount;
                  String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
                  String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
                  if (compress) filename = filename + GZIP_EXTENSION;
                  currentFile = new File(parentDirectory, filename);
                  OutputStream fileStream = new FileOutputStream(currentFile);
                  if (compress) fileStream = new GZIPOutputStream(fileStream);
                  stream = new BufferedOutputStream(fileStream);
              }
              Json.write(document, stream);
              // Need to append a non-consumable character so that we can read multiple JSON documents per file
              stream.write((byte)'\n');
          } catch (IOException e) {
              problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
          }
      }