Add string-based file writing method.