Your problem is that ls prints file names without a path.
So your $file gets the values
DocList.txt Letter mypasswdfile samples things touchfile
from cycle to cycle.
If your current directory is NOT ~/Documents , testing these file names is incorrect, as it will be a search in the current directory, not the intended one.
The best way to accomplish your task is
for file in ~/Documents/* ; do ... done
which will set $file for each full path name needed to find your file.
After that, it should work, but it is very error prone: as soon as your path or one of your files begins to contain a space or other empty character, it will fall to its feet.
Putting " around variables that could potentially contain something with space, etc., is very important. It makes little sense to use a variable without its environment. "
What is the difference?
With [ -f $file ] and file='something with spaces' , [ is called with the arguments -f , something , with , spaces and ] . This, of course, leads to abnormal behavior.
OTOH, with [ -f "$file" ] and file='something with spaces' , [ called with arguments -f , something with spaces and ] .
So quoting is very important in shell programming.
Of course, the same is true for [ -d "$file" ] .