write to text file but needs fixing