fixing file append problems