Fixed appending file bug