A classic example of open literature would be the Gutenberg project of freely available ebooks, but you could also stick to large email collections such as the Enron data set that might better reflect the actual frequency distributions in communications between humans, or even crawl all Wikipedia articles.
The first two mentioned resources can be found on the open science data cloud.
Archives of Wikipedia articles from many different languages can also be found online.
If you decide to crawl the data yourself keep in mind that the frequencies differ based on the language the plain text is written in before encrypting it with one of the weak, frequency preserving crypto systems. Choose sample data in the correct language or your results may mislead you.
However, keep in mind that you do not need to reinvent everything from scratch.
Frequency distribution is a well-researched topic and your script could use precomputed tables by other persons.
This is especially of interest, as frequency analysis has only an educational purpose and can mostly not be used to analyse real-world crypto.
The wikipedia article on letter frequencies is a good source for many different languages. Recheck their sources to ensure how they were built (for example, the english ones are taken from a dictionary, while the portuguese ones are taken from literature).