This is fine.  It is generally better to create the entire file as a string.