You can remove outliers without a loop, try this:
Student <- c("A", "B", "C", "D", "E")
Test1 <- c(45, 36, 41, 42, 15)
Test2 <- c(47, 42, 38, 34, 44)
Test3 <- c(39, 41, 35, 21, 48)
Test4 <- c(13, 45, 42, 35, 37)
Test5 <- c(36, 38, 42, 14, 47)
Dummy <- data.frame(Student, Test1, Test2, Test3, Test4, Test5)
out <- outlier(Dummy[,2:6], logical=TRUE)
out <- cbind(FALSE, out)
# Actual outlier values
Dummy[which(out[,], TRUE)]
# Row and column numbers of the outliers
which(out[,], TRUE)