%% Append Documents to Text File
% Write an array of documents to a text file by appending the documents one at a time.
% Create an array of tokenized documents.

documents = tokenizedDocument([
    "an example of a short sentence" 
    "a second short sentence"])

% Write the first document to the file.

filename = "documents.txt";
writeTextDocument(documents(1),filename)

% View the contents of the file using extractFileText.

str = extractFileText(filename)

% Append the second document to the text file.

writeTextDocument(documents(2),filename,'Append',true)

% View the contents of the file using extractFileText.

str = extractFileText(filename)

% Copyright 2012 The MathWorks, Inc.