Changed binary write to text write.
Modified read/write mode in text mode instead of binary.