Find & fix write to file bug