Fixed overrwriten file bug