Moved echoing of output outside if statement