fixing check for existing output files