import markovify

# Get raw text as string.
with open("poems.txt") as f:
    text = f.read()

# Build the model.
text_model = markovify.Text(text)

longtext = ""

# Print three randomly-generated sentences of no more than 140 characters
for i in range(15):
    longtext += text_model.make_short_sentence(80) + "\n"

with open("generated.txt", "a") as myfile:
    myfile.write(longtext)