It will be better to use `StringIO` to keep this data in memory, instead of writing it out to disk and then immediately reading it back in.