<AddTo ...> is based off insertion point, not total line number.
<AddTo 2>
func testfunc: ....
....
Will add to line 2 of testfunc, not line 2 of the file.
For base files, you cannot define anything before the "extends Node" statement. Godot requires all files to begin with that. (Or begin with extending a subclass of Node)