Change to POSIX compliant loop