working, bug in file writing