Fixed a big bug in tryInsertFile