Split writer method into writeString and writeFile