implemented old c-style file writing