allowed for writing to string as well as file