refactored file handles and loading twig environment within SitemapIndexWriter