When you use an infinitive to start a sentence, be sure that it does not dangle but refers to an appropriate noun or pronoun. To get a good mark, regular attendance is necessary. Now it is clear that we are talking here about the student . The same principle holds if the infinitive comes later in the sentence. You still must avoid creating a dangling modifier, a construction in which the infinitive has nothing to complete it.
Extreme care is necessary to avoid damage to the machine.
In this sentence the infinitive to avoid does not have any person to refer to. When the infinitive functions as the subject or the object of the main verb, it functions as a noun, and you therefore do not have to worry about anything it might modify. Sharon always tries to diligently complete her work. Here the infinitive to complete is split by the adverb diligently . Sharon always tries diligently to complete her work.