I think you can remove this if statement. If the log is empty, you will not be able to get anything.