Why can’t I remove a file inside a while-read loop with a Bash script?

I have a polling script that will occasionally pop out the name of a file to delete. The file to delete will always be located on an NFS-mounted filesystem.

So I wrote this Bash script:

#!/bin/bash
 
/usr/local/bin/polling.sh |
while read FILE_TO_DELETE;
do
   rm "${FILE_TO_DELETE}"
done

When this script is run, I get:

“cannot remove ‘/file/that/needs/deleting.txt’: Device or resource busy”.

If I run the rm command outside the while-read loop, it works just fine, so it’s not a permission or open file issue.

Can anyone explain why the rm command doesn’t work inside this loop but works fine outside of it?