Making sure filename exists before using it