Apparently there was no need to handle spaces in filenames and my way of trying to handle it didn't work.