Fixed write/append file - small bug