Fixed file appending issue