Fix issue where incorrect grid type gets written

The type of the grid group is used, thus, changes are made so that it uses the
grid's type.
Export XML to a file instead of stdout
Fix XML file for Lv1