I'm not a lawyer and so my answer will be from tech point of view.
I don't think that it is possible to make particular line of source code closed source when other part of file is open source, cause that line and corresponding file won't have sense without each other.
You may make some part of your code closed source, but only in programming languages which allow binary distribution. I mean languages which can be compiled in some binary format.
EDIT: Closed source (In my opinion) means that source code of your product aren't shared with end user.