The progtlramme reads data endlessly but I have no idea which loop is incorrect