delivered the opinion of the Court.
Defendant having been sentenced to serve from ten to twelve years’ imprisonment for statutory rape as a second offense, filed a petition for habeas corpus after having served more than two years, attacking the legality of the sentence imposed on him because it did not conform to the provisions of Act No. 295 of April 10, 1946 (Sess. Laws, p. 758, 34 L.P.R.A. § 1024). This petition was granted and he was resentenced to serve from ten to fifteen years’ imprisonment in the penitentiary.1 He appeals from this judgment and alleges that it is contrary to the constitutional provision that protects every individual from being punished twice for the same offense.
*415Appellant maintains that once he was sentenced and had started to serve his term, he could not be resentenced. To back his assertion he rests on Ex parte Lange, 18 Wall. U.S. 163, 21 L. Ed. 872 (1873). But once we examine the facts of the case cited, we find that they are different from the case at bar. In Lange the accused was sentenced to one year in jail and to pay a fine of $200. After serving five days of the term imposed he paid the fine. He then filed a petition for habeas corpus and asserted the illegality of the sentence pronounced since the statute which authorized the imposition of the penalty established fine or imprisonment. He was then sentenced to serve one year in jail. He appealed and the Supreme Court of the United States upon finally deciding the case, upheld petitioner’s contention on the ground that having served one of the penalties imposed by the law, he could not be resentenced. See De Benque v. United States, 85 F.2d 202 (D.C. Cir. 1936).
Now, in the instant case the defendant challenged the sentence imposed because it did not conform to law. It is on his initiative that the sentence was set aside. It has been held that under these circumstances the trial court is in a position to resentence without in any manner whatsoever violating the constitutional provision which prevents an individual from being punished twice for the same offense. It is considered that the accused upon filing his petition— appeal or habeas corpus — which vacates the judgment, waives his right not to be punished twice for the same offense. Murphy v. Massachusetts, 177 U.S. 155 (1900); United States v. Nash, 264 F.2d 610, 613 (8th Cir. 1959); Robinson v. United States, 144 F.2d 392 (6th Cir. 1944); Northcott v. Hand, 352 F.2d 450 (Kan. 1960); State v. Jackson, 82 N.W.2d 234 (Minn. 1957); Commonwealth v. Martin, 127 A.2d 660 (Penn. 1956). Annotation, 97 A.L.R. 160, 162; 1 Wharton, Criminal Law & Procedure § 142 (12th ed. 1957). *416In fact, this Court has followed this doctrine in Sánchez v. Angelí, 80 P.R.R. 154 (1957) and Serrano v. Delgado, Warden, 80 P.R.R. 215 (1958).
Referring to a similar situation of facts, the Supreme Court of the United States in In re Bonner, 151 U.S. 242 (1894), citing an opinion of the Supreme Court of Pennsylvania, stated thus:
“The common law embodies in itself sufficient reason and common sense to reject the monstrous doctrine that a prisoner, whose guilt is established, by a regular verdict, is to escape punishment altogether, because the court committed an error in passing the sentence. If this court sanctioned such a rule, it would fail to perform the chief duty for which it was established.”
Defendant presents an additional question. He alleges that if the power of the trial court to resentence him were upheld, it could not impose a greater penalty than the one imposed-on him by the first sentence. According to the facts, in this case appellant is not correct. It is not the case in which the court attempts motu proprio to alter a sentence which has already been imposed. We must keep in mind that it was by appellant’s own action that the first sentence was set aside because it did not comply with the law. We deem it proper to cite the Supreme Court of the United States in Murphy v. Massachusetts, supra. It says:
“We repeat that this is not a case in which the court undertook to impose in invitum a second or additional sentence for the same offense, or to substitute one sentence for another. On the contrary, plaintiff in error availed himself of his right to have the first sentence annulled so that another sentence might be rendered. And as the decision which he sought and obtained involved the determination that he had been improperly sentenced under chapter 504 of the Statutes of 1895, providing for so-called indeterminate sentences, but should have been sentenced under antecedent statutes, which differed from that, it followed *417that the second sentence must be a new sentence to the extent of those differences, and might turn out to be for a longer period of imprisonment.”
And in Bozza v. United States, 330 U.S. 160, 166-167 (1947), it is stated:
“... Petitioner contends, however, that these cases are. inapplicable here because correction of this sentence so as to. make it lawful increases his punishment. Cf. United States v. Benz, 282 U.S. 304, 309. If this inadvertent error cannot be corrected in the manner used here by the trial court, no valid and enforceable sentence can be imposed at all. Cf. Jordan v. United States, 60 F.2d 4, 6, with Barrow v. United States, 54 App. D. C. 128, 295 F. 949. This Court has rejected the ‘doctrine that a prisoner, whose guilt is established, by a regular verdict, is to escape punishment altogether, because the court committed an error in passing the sentence.’ In re Bonner, supra at 260. The Constitution does not require that sentencing* should be a game in which a wrong move by the judge means immunity for the prisoner. See King v. United States, 69 App. D. C. 10, 15, 98 F.2d 291, 296. In this case the court ‘only set aside what it had no authority to do and substitute [d] directions required by the law to be done upon the conviction of the offender.’ In re Bonner, supra at 260. It did not twice put petitioner in jeopardy for the same offense. The sentence, as corrected, imposes a valid punishment for an offense instead of an invalid punishment for that offense.”
None of the errors assigned having been committed, the judgment appealed from will be affirmed.
According to the provisions of §§ 56 and 258 of the Penal Code (33 L.P.R.A. $§ 131 and 964) the minimum penalty for the second offense of statutory rape is ten years. Cf. González v. Warden, 79 P.R.R. 41 (1956).