I tried to load the file into the property and iterate over it, it worked fine for me:
<loadfile property="file-content" srcFile="${fileWithModules}"/> <foreach target="compile-module" list="${file-content}" delimiter="${line.separator}" param="your-param-used-in-target"/>
source share