added spaces replacement and removal of empty lines