change to a more descriptive variable name
bugfix: check if file exists and it's not a directory