Fix copying filename raising an exception

#KT-4990 Fixed