Fixed file writing for ST files