is it possible to write in to a file in an specific position
Using which library? Some have seek() methods that let you position the insert point. Otherwise, your choices are at the start, and then truncate, or at the end.
Keep in mind that writing at a specific point only makes sense for fixed length records.