getting file name outside the loop