removing trialing spaces and empty lines