If you do this using two different airlines it's not a problem. If you do this using the same airline then it is a problem as far as the airline is concerned. I think it's called "nesting" and is against the rules. Someone else can probably explain the details of it better than me.