Added overwriting functionality

added handling for overwriting files