Correcting reversed looping construct output