Fixed error that append to file instead of overwriting.