Changed write mode to write instead of append