recreated stlwrite.py