Added safety checks for file existence and now unlinks generated gz file if it failed