minor cleanup of file writing code based on code review feedback