refactored append file