changed to appending instead of overwriting after reading