repaire titov write to file function